UNPKG

@tidecloak/js

Version:

TideCloak client side JS SDK

36 lines 1.51 kB
var _a; import { sign, signAsync, signNonDeterministicAsync, verifyAsync } from "../../../Ed25519.js"; import BaseScheme from "../BaseScheme.js"; import { SchemeType } from "../SchemeRegistry.js"; import { Ed25519PrivateComponent, Ed25519PublicComponent, Ed25519SeedComponent } from "./Ed25519Components.js"; class Ed25519Scheme extends BaseScheme { static get Name() { return "Ed25519Scheme"; } } _a = Ed25519Scheme; /** * WITHOUT DETERMINISM. Prefix is generated via randomisation. * @returns */ Ed25519Scheme.GetSigningFunction = () => { const signingFunc = (msg, component) => { if (msg instanceof Uint8Array && component instanceof Ed25519PrivateComponent) { return signNonDeterministicAsync(msg, component.priv); } throw Error("Mismatch of expected types (Uint8Array, Ed25519PrivateComponent)"); }; return signingFunc; }; Ed25519Scheme.GetVerifyingFunction = () => { const verifyingFunc = async (msg, signature, component) => { if (msg instanceof Uint8Array && signature instanceof Uint8Array && component instanceof Ed25519PublicComponent) { const valid = await verifyAsync(signature, msg, component.rawBytes); if (!valid) throw Error("Signature validation failed"); } else throw Error("Mismatch of expected types (Uint8Array, Uint8Array, Ed25519PublicComponent)"); }; return verifyingFunc; }; export default Ed25519Scheme; //# sourceMappingURL=Ed25519Scheme.js.map