Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BearerDID getSigner function #7

Merged
merged 2 commits into from
Feb 6, 2024
Merged

BearerDID getSigner function #7

merged 2 commits into from
Feb 6, 2024

Conversation

amika-sq
Copy link
Contributor

@amika-sq amika-sq commented Feb 5, 2024

Depends on part 1

Adds a getSigner function to BearerDID. It can be called in the following way:

let didJWK = try DIDJWK.create(keyManager: InMemoryKeyManager())
let signer = try didJWK.getSigner()

let signature = try signer.sign(payload: payload)
let isValid = try signer.verify(payload: payload, signature: signature)

You can also provide an optional verificationMethodID, which can be used to specify which verification method to use with the signer. If it's an invalid verification method identifier, the function will throw an error. Example usage:

let didJWK = try DIDJWK.create(keyManager: InMemoryKeyManager())
let signer = try didJWK.getSigner(verificationMethodID: "1234")

let signature = try signer.sign(payload: payload)
let isValid = try signer.verify(payload: payload, signature: signature)

if let verificationMethodID {
verificationMethod = document.verificationMethod?.first { $0.id == verificationMethodID }
} else {
verificationMethod = document.verificationMethod?.first
Copy link
Contributor Author

@amika-sq amika-sq Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just defaulting to the first verification method for now, but we could change this.

If we want this to differ based on the DID Method that created this BearerDID, we'd need to do some additional mapping of the did.methodName (which is just a raw string right now) function to it's appropriate DID method.

@amika-sq
Copy link
Contributor Author

amika-sq commented Feb 5, 2024

current getSigner pseudo-spec here: decentralized-identity/web5-spec#112

Base automatically changed from dids-refactor-part1 to main February 6, 2024 16:55
@amika-sq amika-sq force-pushed the dids-refactor-part2 branch from 4e441c7 to f98b30c Compare February 6, 2024 16:55
@amika-sq amika-sq marked this pull request as ready for review February 6, 2024 16:55
@amika-sq amika-sq closed this Feb 6, 2024
@amika-sq amika-sq reopened this Feb 6, 2024
@amika-sq amika-sq enabled auto-merge (squash) February 6, 2024 16:56
@amika-sq amika-sq merged commit 78d4141 into main Feb 6, 2024
2 checks passed
@amika-sq amika-sq deleted the dids-refactor-part2 branch February 6, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant