Beispiel #1
0
  /**
   * Initializes the internal {AndreevEcdsaBlindingContext}.
   *
   * @param {KeyManager} key_manager
   *    A {KeyManager} containing the signers public key which is necessary
   *    to extract the elliptic curve public parameter.
   * @param {BigInteger} token
   *    This is used to validate the blinded request.
   */
  async initContext(key_manager, token)
  {
    assert(check.isKeyManagerForEcdsaSign(key_manager));
    assert(check.isBigInteger(token));

    const context = EcdsaBlindingContext.fromKey(key_manager);
    context.blinding_factor = {
      a: await util.generateRandomScalar(context.curve),
      b: await util.generateRandomScalar(context.curve),
      c: await util.generateRandomScalar(context.curve),
      d: await util.generateRandomScalar(context.curve)
    };

    context.hashed_token = util.calculateSha512(token);

    this.context = context;
    this.key_manager = key_manager;
    this.token = token;
  }
Beispiel #2
0
  /**
   * Calculates the second part of the ECDSA signature.
   * Based on the blinded key packet payload send to the signer.
   *
   * @param {BlindSignaturePacket} packet
   *    Key package with prepared raw signature data.
   * @returns {BigInteger}
   *    The unblinded signed signature data.
   */
  async requestSecondSignatureParameter(packet)
  {
    assert(packet instanceof BlindSignaturePacket);
    assert(check.isBigInteger(packet.raw_signature));
    assert(EcdsaBlindingContext.isValidBlindingContext(this.context));

    const hash = util.calculateSha512(packet.raw_signature);
    const message = packet.key.pub.trunc_hash(hash.toBuffer());
    const blinded_message = this.blind(message);
    const signed_blinded_message = await server.requestAndreevEcdsaBlinding(blinded_message, this.context);
    return this.unblind(signed_blinded_message);
  }
Beispiel #3
0
/// TODO
async function prepareBlinding(key_manager)
{
  assert(check.isKeyManager(key_manager));

  const public_key_package = key_manager.get_primary_keypair().pub;
  const curve = public_key_package.curve;
  const n = curve.n;
  const G = curve.G;

  let k = null;
  let Ŕ = null;
  let ŕ = null;

  do {

    k = await util.generateRandomScalar(curve);
    Ŕ = G.multiply(k);
    ŕ = Ŕ.affineX.mod(n);

  } while(ŕ.compareTo(BigInteger.ZERO) === 0);

  return {k, Ŕ};
}
Beispiel #4
0
 .then(key_ascii => util.generateKeyFromString(key_ascii))
Beispiel #5
0
 before(async () => {
   this.key_manager = await util.generateKeyFromString(sample_keys.rsa[1024].pub);
 });