How to use the bcrypto/lib/bn.js.isBN function in bcrypto

To help you get started, we’ve selected a few bcrypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github handshake-org / goosig / lib / js / signature.js View on Github external
init(options) {
    assert(options && typeof options === 'object');
    assert(BN.isBN(options.C2));
    assert(BN.isBN(options.C3));
    assert(BN.isBN(options.t));
    assert(BN.isBN(options.chal));
    assert(BN.isBN(options.ell));
    assert(BN.isBN(options.Aq));
    assert(BN.isBN(options.Bq));
    assert(BN.isBN(options.Cq));
    assert(BN.isBN(options.Dq));
    assert(BN.isBN(options.Eq));
    assert(BN.isBN(options.z_w));
    assert(BN.isBN(options.z_w2));
    assert(BN.isBN(options.z_s1));
    assert(BN.isBN(options.z_a));
    assert(BN.isBN(options.z_an));
    assert(BN.isBN(options.z_s1w));
    assert(BN.isBN(options.z_sa));
    assert(BN.isBN(options.z_s2));

    this.C2 = options.C2;
    this.C3 = options.C3;
    this.t = options.t;
    this.chal = options.chal;
    this.ell = options.ell;
    this.Aq = options.Aq;
    this.Bq = options.Bq;
    this.Cq = options.Cq;
    this.Dq = options.Dq;
github handshake-org / goosig / lib / js / goo.js View on Github external
derive(C1, C2, C3, t, A, B, C, D, E, msg) {
    assert(BN.isBN(C1));
    assert(BN.isBN(C2));
    assert(BN.isBN(C3));
    assert(BN.isBN(t));
    assert(BN.isBN(A));
    assert(BN.isBN(B));
    assert(BN.isBN(C));
    assert(BN.isBN(D));
    assert(BN.isBN(E));
    assert(Buffer.isBuffer(msg));

    const ctx = new SHA256();

    ctx.init();
    ctx.update(constants.HASH_PREFIX);
    ctx.update(this.groupHash);
    ctx.update(C1.fromRed().encode('be', this.size));
    ctx.update(C2.fromRed().encode('be', this.size));
    ctx.update(C3.fromRed().encode('be', this.size));
    ctx.update(t.encode('be', 4));
    ctx.update(A.fromRed().encode('be', this.size));
    ctx.update(B.fromRed().encode('be', this.size));
    ctx.update(C.fromRed().encode('be', this.size));
github handshake-org / goosig / lib / js / goo.js View on Github external
derive(C1, C2, C3, t, A, B, C, D, E, msg) {
    assert(BN.isBN(C1));
    assert(BN.isBN(C2));
    assert(BN.isBN(C3));
    assert(BN.isBN(t));
    assert(BN.isBN(A));
    assert(BN.isBN(B));
    assert(BN.isBN(C));
    assert(BN.isBN(D));
    assert(BN.isBN(E));
    assert(Buffer.isBuffer(msg));

    const ctx = new SHA256();

    ctx.init();
    ctx.update(constants.HASH_PREFIX);
    ctx.update(this.groupHash);
    ctx.update(C1.fromRed().encode('be', this.size));
    ctx.update(C2.fromRed().encode('be', this.size));
    ctx.update(C3.fromRed().encode('be', this.size));
    ctx.update(t.encode('be', 4));
    ctx.update(A.fromRed().encode('be', this.size));
github handshake-org / goosig / lib / js / goo.js View on Github external
derive(C1, C2, C3, t, A, B, C, D, E, msg) {
    assert(BN.isBN(C1));
    assert(BN.isBN(C2));
    assert(BN.isBN(C3));
    assert(BN.isBN(t));
    assert(BN.isBN(A));
    assert(BN.isBN(B));
    assert(BN.isBN(C));
    assert(BN.isBN(D));
    assert(BN.isBN(E));
    assert(Buffer.isBuffer(msg));

    const ctx = new SHA256();

    ctx.init();
    ctx.update(constants.HASH_PREFIX);
    ctx.update(this.groupHash);
    ctx.update(C1.fromRed().encode('be', this.size));
    ctx.update(C2.fromRed().encode('be', this.size));
    ctx.update(C3.fromRed().encode('be', this.size));
    ctx.update(t.encode('be', 4));
    ctx.update(A.fromRed().encode('be', this.size));
    ctx.update(B.fromRed().encode('be', this.size));
    ctx.update(C.fromRed().encode('be', this.size));
    ctx.update(D.fromRed().encode('be', this.size));
github handshake-org / goosig / lib / js / signature.js View on Github external
init(options) {
    assert(options && typeof options === 'object');
    assert(BN.isBN(options.C2));
    assert(BN.isBN(options.C3));
    assert(BN.isBN(options.t));
    assert(BN.isBN(options.chal));
    assert(BN.isBN(options.ell));
    assert(BN.isBN(options.Aq));
    assert(BN.isBN(options.Bq));
    assert(BN.isBN(options.Cq));
    assert(BN.isBN(options.Dq));
    assert(BN.isBN(options.Eq));
    assert(BN.isBN(options.z_w));
    assert(BN.isBN(options.z_w2));
    assert(BN.isBN(options.z_s1));
    assert(BN.isBN(options.z_a));
    assert(BN.isBN(options.z_an));
    assert(BN.isBN(options.z_s1w));
    assert(BN.isBN(options.z_sa));
    assert(BN.isBN(options.z_s2));
github handshake-org / goosig / lib / js / goo.js View on Github external
inv2(b1, b2) {
    assert(BN.isBN(b1));
    assert(BN.isBN(b2));

    const b12i = b1.redMul(b2).redInvert();

    return [
      b2.redMul(b12i),
      b1.redMul(b12i)
    ];
  }
github handshake-org / goosig / lib / js / goo.js View on Github external
inv7(b1, b2, b3, b4, b5, b6, b7) {
    assert(BN.isBN(b1));
    assert(BN.isBN(b2));
    assert(BN.isBN(b3));
    assert(BN.isBN(b4));
    assert(BN.isBN(b5));
    assert(BN.isBN(b6));
    assert(BN.isBN(b7));

    const b12 = b1.redMul(b2);
    const b34 = b3.redMul(b4);
    const b56 = b5.redMul(b6);
    const b1234 = b12.redMul(b34);
    const b123456 = b1234.redMul(b56);
    const b1234567 = b123456.redMul(b7);
    const b1234567i = b1234567.redInvert();
    const b123456i = b1234567i.redMul(b7);
    const b1234i = b123456i.redMul(b56);
    const b56i = b123456i.redMul(b1234);
    const b34i = b1234i.redMul(b12);
    const b12i = b1234i.redMul(b34);

    return [
github handshake-org / goosig / lib / js / goo.js View on Github external
inv7(b1, b2, b3, b4, b5, b6, b7) {
    assert(BN.isBN(b1));
    assert(BN.isBN(b2));
    assert(BN.isBN(b3));
    assert(BN.isBN(b4));
    assert(BN.isBN(b5));
    assert(BN.isBN(b6));
    assert(BN.isBN(b7));

    const b12 = b1.redMul(b2);
    const b34 = b3.redMul(b4);
    const b56 = b5.redMul(b6);
    const b1234 = b12.redMul(b34);
    const b123456 = b1234.redMul(b56);
    const b1234567 = b123456.redMul(b7);
    const b1234567i = b1234567.redInvert();
    const b123456i = b1234567i.redMul(b7);
    const b1234i = b123456i.redMul(b56);
    const b56i = b123456i.redMul(b1234);
    const b34i = b1234i.redMul(b12);
    const b12i = b1234i.redMul(b34);

    return [
      b12i.redMul(b2),
github handshake-org / goosig / lib / js / goo.js View on Github external
inv7(b1, b2, b3, b4, b5, b6, b7) {
    assert(BN.isBN(b1));
    assert(BN.isBN(b2));
    assert(BN.isBN(b3));
    assert(BN.isBN(b4));
    assert(BN.isBN(b5));
    assert(BN.isBN(b6));
    assert(BN.isBN(b7));

    const b12 = b1.redMul(b2);
    const b34 = b3.redMul(b4);
    const b56 = b5.redMul(b6);
    const b1234 = b12.redMul(b34);
    const b123456 = b1234.redMul(b56);
    const b1234567 = b123456.redMul(b7);
    const b1234567i = b1234567.redInvert();
    const b123456i = b1234567i.redMul(b7);
    const b1234i = b123456i.redMul(b56);
    const b56i = b123456i.redMul(b1234);
    const b34i = b1234i.redMul(b12);
    const b12i = b1234i.redMul(b34);
github handshake-org / goosig / lib / js / goo.js View on Github external
sqr(b) {
    assert(BN.isBN(b));
    return b.redSqr();
  }