pike.git / src / post_modules / Nettle / hogweed.cmod

version» Context lines:

pike.git/src/post_modules/Nettle/hogweed.cmod:440:    ecc_scalar_init(&s, THIS->curve);       ecc_scalar_random(&s, rnd, random_func_wrapper);       push_object(ret = fast_clone_object(bignum_program));    ecc_scalar_get(&s, (mpz_ptr)ret->storage);       ecc_scalar_clear(&s);    }    -  /*! @decl array(Gmp.mpz) `*(Gmp.mpz|int scalar) +  static int Nettle_ECC_Curve_Point_program_fun_num; +  +  /*! @decl Point `*(Gmp.mpz|int scalar)    *!    *! Multiply the curve by a scalar.    *!    *! This can be used to get the public key from a private key.    *!    *! @returns -  *! Returns a new point (x, y) on the curve. +  *! Returns a new @[Point] on the curve.    */ -  PIKEFUN array(object(Gmp.mpz)) `*(object(Gmp.mpz)|int scalar) +  PIKEFUN Nettle_ECC_Curve_Point `*(object(Gmp.mpz)|int scalar)    {    struct ecc_scalar s;    struct ecc_point r;    struct object *x;    struct object *y;       if (!THIS->curve) Pike_error("No curve defined.\n");       convert_svalue_to_bignum(scalar);   
pike.git/src/post_modules/Nettle/hogweed.cmod:477:    }       ecc_point_mul_g(&r, &s);    push_object(x = fast_clone_object(bignum_program));    push_object(y = fast_clone_object(bignum_program));    ecc_point_get(&r, (mpz_ptr)x->storage, (mpz_ptr)y->storage);       ecc_scalar_clear(&s);    ecc_point_clear(&r);    -  f_aggregate(2); +  apply_current(Nettle_ECC_Curve_Point_program_fun_num, 2);    }    -  /*! @decl array(Gmp.mpz) point_mul(Gmp.mpz|int x, Gmp.mpz|int y, @ -  *! Gmp.mpz|int scalar) +  /*! @decl Point point_mul(Gmp.mpz|int x, Gmp.mpz|int y, @ +  *! Gmp.mpz|int scalar)    *!    *! Multiply a point on the curve by a scalar.    *!    *! A typical use is for Elliptic Curve Diffie Hellman (ECDH) key exchange.    *! -  +  *! This is equivalent to @code{(Point(x, y) * scalar)@}. +  *!    *! @returns -  *! Returns the new point on the curve. +  *! Returns the new @[Point] on the curve.    *!    *! @throws    *! Throws an error if the point (@[x], @[y]) isn't on the curve.    */ -  PIKEFUN array(object(Gmp.mpz)) point_mul(object(Gmp.mpz)|int x, +  PIKEFUN Nettle_ECC_Curve_Point point_mul(object(Gmp.mpz)|int x,    object(Gmp.mpz)|int y,    object(Gmp.mpz)|int scalar)    {    struct ecc_point p;    struct ecc_scalar s;    struct ecc_point r;    struct object *rx;    struct object *ry;       if (!THIS->curve) Pike_error("No curve defined.\n");
pike.git/src/post_modules/Nettle/hogweed.cmod:538:    ecc_point_mul(&r, &s, &p);       push_object(rx = fast_clone_object(bignum_program));    push_object(ry = fast_clone_object(bignum_program));    ecc_point_get(&r, (mpz_ptr)rx->storage, (mpz_ptr)ry->storage);       ecc_point_clear(&r);    ecc_scalar_clear(&s);    ecc_point_clear(&p);    -  f_aggregate(2); +  apply_current(Nettle_ECC_Curve_Point_program_fun_num, 2);    stack_pop_n_elems_keep_top(args);    }       /*! @class Point    *!    *! A point on an elliptic curve.    */    PIKECLASS Point    program_flags PROGRAM_USES_PARENT|PROGRAM_NEEDS_PARENT|PROGRAM_CLEAR_STORAGE;    {