How to use the bcrypto/lib/encoding/base16.decode 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 / hs-airdrop / lib / key.js View on Github external
switch (this.type) {
      case keyTypes.RSA: {
        this.n = base16.decode(json.n);
        this.e = base16.decode(json.e);
        this.nonce = base16.decode(json.nonce, 32);
        break;
      }

      case keyTypes.GOO: {
        this.C1 = base16.decode(json.C1);
        break;
      }

      case keyTypes.P256: {
        this.point = base16.decode(json.point, 33);
        this.nonce = base16.decode(json.nonce, 32);
        break;
      }

      case keyTypes.ED25519: {
        this.point = base16.decode(json.point, 32);
        this.nonce = base16.decode(json.nonce, 32);
        break;
      }

      case keyTypes.ADDRESS: {
        assert((json.version & 0xff) === json.version);
        assert(Number.isSafeInteger(json.value) && json.value >= 0);
        assert(typeof json.sponsor === 'boolean');
        this.version = json.version;
        this.address = base16.decode(json.address);
github handshake-org / hsd / lib / primitives / airdropproof.js View on Github external
for (const hash of json.proof)
      this.proof.push(base16.decode(hash, 32));

    this.subindex = json.subindex;

    for (const hash of json.subproof)
      this.subproof.push(base16.decode(hash, 32));

    if (json.key)
      this.key = AirdropKey.fromJSON(json.key).encode();

    this.version = json.version;
    this.address = base16.decode(json.address);
    this.fee = json.fee;
    this.signature = base16.decode(json.signature);

    return this;
  }
}
github handshake-org / hs-airdrop / lib / proof.js View on Github external
for (const hash of json.proof)
      this.proof.push(base16.decode(hash, 32));

    this.subindex = json.subindex;

    for (const hash of json.subproof)
      this.subproof.push(base16.decode(hash, 32));

    if (json.key)
      this.key = AirdropKey.fromJSON(json.key).encode();

    this.version = json.version;
    this.address = base16.decode(json.address);
    this.fee = json.fee;
    this.signature = base16.decode(json.signature);

    return this;
  }
}
github handshake-org / hs-airdrop / lib / key.js View on Github external
fromJSON(json) {
    assert(json && typeof json === 'object');
    assert(typeof json.type === 'string');
    assert(keyTypes.hasOwnProperty(json.type));

    this.type = keyTypes[json.type];

    switch (this.type) {
      case keyTypes.RSA: {
        this.n = base16.decode(json.n);
        this.e = base16.decode(json.e);
        this.nonce = base16.decode(json.nonce, 32);
        break;
      }

      case keyTypes.GOO: {
        this.C1 = base16.decode(json.C1);
        break;
      }

      case keyTypes.P256: {
        this.point = base16.decode(json.point, 33);
        this.nonce = base16.decode(json.nonce, 32);
        break;
      }

      case keyTypes.ED25519: {
github handshake-org / hs-airdrop / lib / key.js View on Github external
this.nonce = base16.decode(json.nonce, 32);
        break;
      }

      case keyTypes.ED25519: {
        this.point = base16.decode(json.point, 32);
        this.nonce = base16.decode(json.nonce, 32);
        break;
      }

      case keyTypes.ADDRESS: {
        assert((json.version & 0xff) === json.version);
        assert(Number.isSafeInteger(json.value) && json.value >= 0);
        assert(typeof json.sponsor === 'boolean');
        this.version = json.version;
        this.address = base16.decode(json.address);
        this.value = json.value;
        this.sponsor = json.sponsor;
        break;
      }

      default: {
        throw new Error('Unknown key type.');
      }
    }

    return this;
  }
github handshake-org / hsd / lib / primitives / airdropproof.js View on Github external
assert(Array.isArray(json.subproof));
    assert(json.key == null || (json.key && typeof json.key === 'object'));
    assert((json.version & 0xff) === json.version);
    assert(typeof json.address === 'string');
    assert(Number.isSafeInteger(json.fee) && json.fee >= 0);
    assert(typeof json.signature === 'string');

    this.index = json.index;

    for (const hash of json.proof)
      this.proof.push(base16.decode(hash, 32));

    this.subindex = json.subindex;

    for (const hash of json.subproof)
      this.subproof.push(base16.decode(hash, 32));

    if (json.key)
      this.key = AirdropKey.fromJSON(json.key).encode();

    this.version = json.version;
    this.address = base16.decode(json.address);
    this.fee = json.fee;
    this.signature = base16.decode(json.signature);

    return this;
  }
}
github handshake-org / hs-airdrop / lib / key.js View on Github external
fromJSON(json) {
    assert(json && typeof json === 'object');
    assert(typeof json.type === 'string');
    assert(keyTypes.hasOwnProperty(json.type));

    this.type = keyTypes[json.type];

    switch (this.type) {
      case keyTypes.RSA: {
        this.n = base16.decode(json.n);
        this.e = base16.decode(json.e);
        this.nonce = base16.decode(json.nonce, 32);
        break;
      }

      case keyTypes.GOO: {
        this.C1 = base16.decode(json.C1);
        break;
      }

      case keyTypes.P256: {
        this.point = base16.decode(json.point, 33);
        this.nonce = base16.decode(json.nonce, 32);
        break;
      }

      case keyTypes.ED25519: {
        this.point = base16.decode(json.point, 32);
github handshake-org / hs-airdrop / lib / proof.js View on Github external
this.index = json.index;

    for (const hash of json.proof)
      this.proof.push(base16.decode(hash, 32));

    this.subindex = json.subindex;

    for (const hash of json.subproof)
      this.subproof.push(base16.decode(hash, 32));

    if (json.key)
      this.key = AirdropKey.fromJSON(json.key).encode();

    this.version = json.version;
    this.address = base16.decode(json.address);
    this.fee = json.fee;
    this.signature = base16.decode(json.signature);

    return this;
  }
}
github handshake-org / hs-airdrop / lib / key.js View on Github external
break;
      }

      case keyTypes.GOO: {
        this.C1 = base16.decode(json.C1);
        break;
      }

      case keyTypes.P256: {
        this.point = base16.decode(json.point, 33);
        this.nonce = base16.decode(json.nonce, 32);
        break;
      }

      case keyTypes.ED25519: {
        this.point = base16.decode(json.point, 32);
        this.nonce = base16.decode(json.nonce, 32);
        break;
      }

      case keyTypes.ADDRESS: {
        assert((json.version & 0xff) === json.version);
        assert(Number.isSafeInteger(json.value) && json.value >= 0);
        assert(typeof json.sponsor === 'boolean');
        this.version = json.version;
        this.address = base16.decode(json.address);
        this.value = json.value;
        this.sponsor = json.sponsor;
        break;
      }

      default: {
github handshake-org / hsd / lib / primitives / airdropproof.js View on Github external
this.index = json.index;

    for (const hash of json.proof)
      this.proof.push(base16.decode(hash, 32));

    this.subindex = json.subindex;

    for (const hash of json.subproof)
      this.subproof.push(base16.decode(hash, 32));

    if (json.key)
      this.key = AirdropKey.fromJSON(json.key).encode();

    this.version = json.version;
    this.address = base16.decode(json.address);
    this.fee = json.fee;
    this.signature = base16.decode(json.signature);

    return this;
  }
}