@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
1 lines • 2.29 kB
Source Map (JSON)
{"version":3,"file":"X25519PublicJwk.mjs","names":[],"sources":["../../../../../../src/modules/kms/jwk/kty/okp/X25519PublicJwk.ts"],"sourcesContent":["import { KnownJwaKeyAgreementAlgorithms, type KnownJwaSignatureAlgorithm } from '../../jwa'\nimport type { PublicJwkType } from '../PublicJwk'\nimport type { KmsJwkPublicOkp } from './okpJwk'\nimport { okpPublicJwkToPublicKey, okpPublicKeyToPublicJwk } from './okpPublicKey'\n\ntype Jwk = KmsJwkPublicOkp & { crv: 'X25519' }\n\nexport class X25519PublicJwk implements PublicJwkType<Jwk> {\n public static supportedEncryptionKeyAgreementAlgorithms = [KnownJwaKeyAgreementAlgorithms.ECDH_HSALSA20]\n public static supportedSignatureAlgorithms: KnownJwaSignatureAlgorithm[] = []\n public static multicodecPrefix = 236\n\n public supportedEncryptionKeyAgreementAlgorithms = X25519PublicJwk.supportedEncryptionKeyAgreementAlgorithms\n public supportedSignatureAlgorithms = X25519PublicJwk.supportedSignatureAlgorithms\n public multicodecPrefix = X25519PublicJwk.multicodecPrefix\n\n public constructor(public readonly jwk: Jwk) {}\n\n public get publicKey() {\n return {\n crv: this.jwk.crv,\n kty: this.jwk.kty,\n publicKey: okpPublicJwkToPublicKey(this.jwk),\n }\n }\n\n /**\n * Not supported for X25519\n */\n public get compressedPublicKey() {\n return null\n }\n\n public get multicodec() {\n return okpPublicJwkToPublicKey(this.jwk)\n }\n\n public static fromPublicKey(publicKey: Uint8Array) {\n const jwk = okpPublicKeyToPublicJwk(publicKey, 'X25519')\n return new X25519PublicJwk(jwk)\n }\n\n public static fromMulticodec(multicodec: Uint8Array) {\n const jwk = okpPublicKeyToPublicJwk(multicodec, 'X25519')\n return new X25519PublicJwk(jwk)\n }\n}\n"],"mappings":";;;;;;AAOA,IAAa,kBAAb,MAAa,gBAA8C;CASzD,AAAO,YAAY,AAAgB,KAAU;EAAV;OAJ5B,4CAA4C,gBAAgB;OAC5D,+BAA+B,gBAAgB;OAC/C,mBAAmB,gBAAgB;;CAI1C,IAAW,YAAY;AACrB,SAAO;GACL,KAAK,KAAK,IAAI;GACd,KAAK,KAAK,IAAI;GACd,WAAW,wBAAwB,KAAK,IAAI;GAC7C;;;;;CAMH,IAAW,sBAAsB;AAC/B,SAAO;;CAGT,IAAW,aAAa;AACtB,SAAO,wBAAwB,KAAK,IAAI;;CAG1C,OAAc,cAAc,WAAuB;AAEjD,SAAO,IAAI,gBADC,wBAAwB,WAAW,SAAS,CACzB;;CAGjC,OAAc,eAAe,YAAwB;AAEnD,SAAO,IAAI,gBADC,wBAAwB,YAAY,SAAS,CAC1B;;;gBApCnB,4CAA4C,CAAC,+BAA+B,cAAc;gBAC1F,+BAA6D,EAAE;gBAC/D,mBAAmB"}