src/disj.c
/*
 * Verify for a single key.
 * Y^c == G^s * t
 */
Verify for a single key.
Verify for a single key .
golle_error check_key (const golle_schnorr_t *key,
		       const golle_num_t s,
		       const golle_num_t t,
		       const golle_num_t c)
{
  golle_error err = GOLLE_OK;
  BIGNUM *yc = NULL, *gs = NULL, *gst = NULL;
  BN_CTX *ctx = BN_CTX_new ();
  GOLLE_ASSERT (ctx, GOLLE_EMEM);
  BN_CTX_start (ctx);
  if (!(yc = BN_CTX_get (ctx))) {
    err = GOLLE_EMEM;
    goto out;
  }
  if (!BN_mod_exp (yc, key->Y, c, key->p, ctx)) {
    err = GOLLE_EMEM;
    goto out;
  }
  if (!(gs = BN_CTX_get (ctx)) ||
      !(gst = BN_CTX_get (ctx))) {
    err = GOLLE_EMEM;
    goto out;
  }
  if (!BN_mod_exp (gs, key->G, s, key->p, ctx)) {
    err = GOLLE_EMEM;
    goto out;
  }
  if (!BN_mod_mul (gst, gs, t, key->p, ctx)) {
    err = GOLLE_EMEM;
    goto out;
  }
  if (BN_cmp (gst, yc) != 0) {
    err = GOLLE_ECRYPTO;
  }
 out:
  BN_CTX_free (ctx);
  return err;
}
golle_error check_key ( const golle_schnorr_t * key , const golle_num_t s , const golle_num_t t , const golle_num_t c ) { golle_error err = GOLLE_OK ; BIGNUM * yc = NULL , * gs = NULL , * gst = NULL ; BN_CTX * ctx = BN_CTX_new ( ) ; GOLLE_ASSERT ( ctx , GOLLE_EMEM ) ; BN_CTX_start ( ctx ) ; if ( ! ( yc = BN_CTX_get ( ctx ) ) ) { err = GOLLE_EMEM ; goto out ; } if ( ! BN_mod_exp ( yc , key -> Y , c , key -> p , ctx ) ) { err = GOLLE_EMEM ; goto out ; } if ( ! ( gs = BN_CTX_get ( ctx ) ) || ! ( gst = BN_CTX_get ( ctx ) ) ) { err = GOLLE_EMEM ; goto out ; } if ( ! BN_mod_exp ( gs , key -> G , s , key -> p , ctx ) ) { err = GOLLE_EMEM ; goto out ; } if ( ! BN_mod_mul ( gst , gs , t , key -> p , ctx ) ) { err = GOLLE_EMEM ; goto out ; } if ( BN_cmp ( gst , yc ) != 0 ) { err = GOLLE_ECRYPTO ; } out : BN_CTX_free ( ctx ) ; return err ; }
Verify for a single key.
Verify for a single key .
/* Get y^c */ /* Get G^s */ /* Get G^s * t */ /* Ensure they're equal */