Encoding credentials attributes

Hello everyone,

I was wondering how to correctly encode the attributes of a credential. In the example “Issue Credential” SHA-256 is used. In the comments of the Java wrapper you are asked to encode the attribute as int. Is encoding with one-way functions really a good idea, especially since the original value can no longer be reconstructed from the encoding?


Hash is used to convert arbitrarily long data to a fixed size data which can then be converted to a fixed size int.
The encoding is not meant to be reversible. The verifier does not decode the data back to the original (during selective disclosure), but encodes the credential data and compares it with the encoding of expected data. To be precise, any attribute of a credential has to be an element of a prime field which is 32 byte size in our case. To convert any arbitrarily long data to 32 bytes, you hash that to 32 bytes and create a prime field element.
The credentials and proofs only know about the encoded data, not the actual data.

Thanks its clear now :slight_smile:

1 Like