UNPKG

@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.6 kB
{"version":3,"file":"Secp256k1PublicJwk.mjs","names":[],"sources":["../../../../../../src/modules/kms/jwk/kty/ec/Secp256k1PublicJwk.ts"],"sourcesContent":["import { KnownJwaKeyAgreementAlgorithms, type KnownJwaSignatureAlgorithm, KnownJwaSignatureAlgorithms } from '../../jwa'\nimport type { PublicJwkType } from '../PublicJwk'\nimport type { KmsJwkPublicEc } from './ecJwk'\nimport { ecPublicJwkToPublicKey, ecPublicKeyToPublicJwk } from './ecPublicKey'\n\ntype Jwk = KmsJwkPublicEc & { crv: 'secp256k1' }\n\nexport class Secp256k1PublicJwk implements PublicJwkType<Jwk> {\n public static supportedSignatureAlgorithms: KnownJwaSignatureAlgorithm[] = [KnownJwaSignatureAlgorithms.ES256K]\n public static supportedEncryptionKeyAgreementAlgorithms = [KnownJwaKeyAgreementAlgorithms.ECDH_ES]\n public static multicodecPrefix = 231\n\n public supportedEncryptionKeyAgreementAlgorithms = Secp256k1PublicJwk.supportedEncryptionKeyAgreementAlgorithms\n public supportedSignatureAlgorithms = Secp256k1PublicJwk.supportedSignatureAlgorithms\n public multicodecPrefix = Secp256k1PublicJwk.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: ecPublicJwkToPublicKey(this.jwk),\n }\n }\n\n public get compressedPublicKey() {\n return {\n crv: this.jwk.crv,\n kty: this.jwk.kty,\n publicKey: ecPublicJwkToPublicKey(this.jwk, { compressed: true }),\n }\n }\n\n public get multicodec() {\n return ecPublicJwkToPublicKey(this.jwk, { compressed: true })\n }\n\n public static fromPublicKey(publicKey: Uint8Array) {\n const jwk = ecPublicKeyToPublicJwk(publicKey, 'secp256k1')\n return new Secp256k1PublicJwk(jwk)\n }\n\n public static fromMulticodec(multicodec: Uint8Array) {\n const jwk = ecPublicKeyToPublicJwk(multicodec, 'secp256k1')\n return new Secp256k1PublicJwk(jwk)\n }\n}\n"],"mappings":";;;;;;AAOA,IAAa,qBAAb,MAAa,mBAAiD;CAS5D,AAAO,YAAY,AAAgB,KAAU;EAAV;OAJ5B,4CAA4C,mBAAmB;OAC/D,+BAA+B,mBAAmB;OAClD,mBAAmB,mBAAmB;;CAI7C,IAAW,YAAY;AACrB,SAAO;GACL,KAAK,KAAK,IAAI;GACd,KAAK,KAAK,IAAI;GACd,WAAW,uBAAuB,KAAK,IAAI;GAC5C;;CAGH,IAAW,sBAAsB;AAC/B,SAAO;GACL,KAAK,KAAK,IAAI;GACd,KAAK,KAAK,IAAI;GACd,WAAW,uBAAuB,KAAK,KAAK,EAAE,YAAY,MAAM,CAAC;GAClE;;CAGH,IAAW,aAAa;AACtB,SAAO,uBAAuB,KAAK,KAAK,EAAE,YAAY,MAAM,CAAC;;CAG/D,OAAc,cAAc,WAAuB;AAEjD,SAAO,IAAI,mBADC,uBAAuB,WAAW,YAAY,CACxB;;CAGpC,OAAc,eAAe,YAAwB;AAEnD,SAAO,IAAI,mBADC,uBAAuB,YAAY,YAAY,CACzB;;;mBArCtB,+BAA6D,CAAC,4BAA4B,OAAO;mBACjG,4CAA4C,CAAC,+BAA+B,QAAQ;mBACpF,mBAAmB"}