hyperledger / anoncreds-spec

The specification for AnonCreds verifiable credential exchange.
https://hyperledger.github.io/anoncreds-spec/
Apache License 2.0
45 stars 24 forks source link

Added tails file prime generation and tails file hashing #148

Closed aritroCoder closed 1 year ago

aritroCoder commented 1 year ago

Before: image

After: image image

andrewwhitehead commented 1 year ago

The entries in the tails file aren't actually primes, they are G2 curve points. The process for generating them looks correct here. Essentially, it is the case that tail[index] = g_dash * (gamma ** index), where gamma is a scalar field element. I'm not sure I would describe g_dash as 'the' generator of the G2 group as it seems to be picked randomly for each registry. Every curve point is technically a generator but there is also a standard one that is used elsewhere.

aritroCoder commented 1 year ago

The entries in the tails file aren't actually primes, they are G2 curve points. The process for generating them looks correct here. Essentially, it is the case that tail[index] = g_dash * (gamma ** index), where gamma is a scalar field element. I'm not sure I would describe g_dash as 'the' generator of the G2 group as it seems to be picked randomly for each registry. Every curve point is technically a generator but there is also a standard one that is used elsewhere.

image This text is from another part of the same specification where they call g_dash as the generator.

And thanks for the clarification, I was also wondering if they are actually a prime number or not

aritroCoder commented 1 year ago

I have updated the first message with the new updated screenshot of edited spec. Also, I have changed the mention of primes with points in curve G2 in that section (I guess it needs a separate issue to track down and replace all such instances in case this is present elsewhere too)

swcurran commented 1 year ago

Looks great — nice work. A few minor cleanups mostly in the text that existed before you started.

Not sure about the “To Do” right below your PR. Is there something you can add about for the format of the file (e.g. how to extract the points from it), or should it be removed?

aritroCoder commented 1 year ago

Looks great — nice work. A few minor cleanups mostly in the text that existed before you started.

Not sure about the “To Do” right below your PR. Is there something you can add about for the format of the file (e.g. how to extract the points from it), or should it be removed?

for the TO DO where we have to define the format of the tails file, I am guessing we have to write what all data is written in the file, and in which order, something like this:

image

But I am not sure how to write the format for the tails file as they are not in human readable format but as octet-stream, so giving an example won't be useful.

mikelodder7 commented 1 year ago

The values are elliptic curve points and not primes encoded. I need to look deeper as to how those points are encoded

aritroCoder commented 1 year ago

The values are elliptic curve points and not primes encoded. I need to look deeper as to how those points are encoded

Yeah, that's the reason why they are encoded to the octet stream, which makes it difficult to create a human understandable format

andrewwhitehead commented 1 year ago

The points are encoded as uncompressed big-endian coordinates: {x.0, x.1, y.0, y.1} for 32*4 = 128 bytes, for the two Fp2 components.

aritroCoder commented 1 year ago

The points are encoded as uncompressed big-endian coordinates: {x.0, x.1, y.0, y.1} for 32*4 = 128 bytes, for the two Fp2 components.

I think for a schematic format I can add this. In the code comments however, the byte order was mentioned as 'little' so it should be little endian

aritroCoder commented 1 year ago

I have updated the first message with the new updated screenshot of edited spec after adding the tails file format