-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: implement rsa signer / verifier #102
Conversation
Co-authored-by: Hugo Dias <[email protected]>
readonly verifier: EdVerifier<M> | ||
|
||
readonly code: 0x1300 | ||
encode(): ByteView<EdSigner<M>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encode(): ByteView<EdSigner<M>> | |
encode(): ByteView<EdSigner<M>> | |
export(): ByteView<EdSigner<M>> |
readonly signatureCode: CODE | ||
readonly signatureAlgorithm: ALG | ||
|
||
encode: () => ByteView<EdVerifier<M>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encode: () => ByteView<EdVerifier<M>> | |
encode: () => ByteView<EdVerifier<M>> | |
export: () => ByteView<EdVerifier<M>> |
packages/principal/src/rsa.js
Outdated
} | ||
async export() { | ||
const pkcs8 = await webcrypto.subtle.exportKey('pkcs8', this.key) | ||
return tagWith(code, PKCS8.decode(new Uint8Array(pkcs8))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache bytes in this.bytes
packages/interface/src/lib.ts
Outdated
export?: () => Await<ByteView<Signer<M, A>>> | ||
toCryptoKey?: () => Await<CryptoKey> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export?: () => Await<ByteView<Signer<M, A>>> | |
toCryptoKey?: () => Await<CryptoKey> | |
exportBytes?: () => Await<ByteView<Signer<M, A>>> | |
exportKey?: () => Await<CryptoKey> |
packages/interface/src/lib.ts
Outdated
export?: () => Await<ByteView<Verifier<M, A>>> | ||
toCryptoKey?: () => Await<CryptoKey> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export?: () => Await<ByteView<Verifier<M, A>>> | |
toCryptoKey?: () => Await<CryptoKey> | |
exportBytes?: () => Await<ByteView<Verifier<M, A>>> | |
exportKey?: () => Await<CryptoKey> |
@hugomrdias I have trimmed interface per your feedback. Now I hope these changes address your concerns, please have another pass and let me know whether to proceed or if there are some other concerns to be addressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* @param {string|undefined} input | ||
* @returns | ||
*/ | ||
const base6urlDecode = (input = '') => base64url.baseDecode(input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const base6urlDecode = (input = '') => base64url.baseDecode(input) | |
const base64urlDecode = (input = '') => base64url.baseDecode(input) |
Co-authored-by: Hugo Dias <[email protected]>
General overview of changes:
UCAN.Signer
interface withtoArchive(): SignerArchive
method which can be used to save signers across sessions.SignerArchive
is a type union that represents either binary encoded private key with multiformat code, or{ did: string, key: CryptoKey }
struct that can be stored in indexdb.SignerImporter
interface withfrom(archive:SignerArchive): Signer
method, which can be used to import archived signer. In other wordsimporter.from(signer.toArchive())
roundtrips.SignerImporter
we havePrincipalParser
withparse(did:DID): Verifire
method, which can be used to turn verifiers to DIDs and backparser.parse(verifier.did())
.@ucanto/principal
now providesSigner
export which is composed RSA and EdSignerImporter
.@ucanto/principal
now providesVerifier
export which is composed RSA and EdPrincipalParser
.