UNPKG

@stellot/crypto

Version:

Crypto libraries for front and backend

27 lines (26 loc) 710 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("./index"); const utils_1 = require("./utils"); class SignerSession { constructor(secretKey) { const keypair = index_1.ed25519.keyFromSecret(secretKey); this.x = keypair.priv(); this.P = keypair.pub(); this.k = utils_1.randomScalar(); this.R = index_1.ed25519.curve.g.mul(this.k); } publicKey() { return this.P; } publicNonce() { return this.R; } sign(challenge) { return this.x .mul(challenge) .add(this.k) .umod(index_1.ed25519.curve.n); } } exports.default = SignerSession;