Skip to content

How to exponentiate arbitrary group element instead of ctx->initial? #633

Closed
@vusirikala

Description

@vusirikala

I explored the library and finally came up with the following code for generating a random element on the elliptic curve.

	secp256k1_ecmult_gen_context context;
	void * prealloc = checked_malloc(&default_error_callback, SECP256K1_ECMULT_GEN_CONTEXT_PREALLOCATED_SIZE);

        secp256k1_ecmult_gen_context_init(&context);
        secp256k1_ecmult_gen_context_build(&context, &prealloc);

	unsigned char exp[32];
	secp256k1_scalar exponent;
	secp256k1_gej generator;
	int overflow;
    	secp256k1_rand256(exp);
	secp256k1_scalar_set_b32(&exponent, exp, &overflow);
	secp256k1_ecmult_gen(&context, &generator, &exponent);

The function secp256k1_ecmult_gen raises the context->initial group element to given exponent.

  1. Is there an inbuilt function to raise a given group element to a given exponent?
  2. I see 2 files ecmult_impl.h and ecmult_gen_impl.h. What's the difference?
  3. If my point is in secp256k1_ge group, should I first convert it into secp256k1_gej group using secp256k1_gej_set_ge() function and then apply the above function? Or is there a more efficient way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions