UNPKG

@dedis/kyber

Version:

A typescript implementation of Kyber interfaces

30 lines (29 loc) 887 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const point_1 = require("../../pairing/point"); /** * Sign the message with the given secret key * @param msg the message to sign * @param secret the private key */ function sign(msg, secret) { const HM = point_1.BN256G1Point.hashToPoint(msg); HM.mul(secret, HM); return HM.marshalBinary(); } exports.sign = sign; /** * Verify the signature of the message with the public key * @param msg the message * @param pub the public key as a point * @param sig the signature as a buffer */ function verify(msg, pub, sig) { const HM = point_1.BN256G1Point.hashToPoint(msg); const left = HM.pair(pub); const s = new point_1.BN256G1Point(); s.unmarshalBinary(sig); const right = s.pair(new point_1.BN256G2Point().base()); return left.equals(right); } exports.verify = verify;