diff --git a/crypto/bn254/utils.go b/crypto/bn254/utils.go index 0ba2ebef..0a07007b 100644 --- a/crypto/bn254/utils.go +++ b/crypto/bn254/utils.go @@ -28,9 +28,11 @@ func VerifySig(sig *bn254.G1Affine, pubkey *bn254.G2Affine, msgBytes [32]byte) ( } -// TODO: which algorithm is this implementing? -// -// add details... +// MapToCurve implements the simple hash-and-check (also sometimes try-and-increment) algorithm +// see https://hackmd.io/@benjaminion/bls12-381#Hash-and-check +// Note that this function needs to be the same as the one used in the contract: +// https://github.com/Layr-Labs/eigenlayer-middleware/blob/1feb6ae7e12f33ce8eefb361edb69ee26c118b5d/src/libraries/BN254.sol#L292 +// we don't use the newer constant time hash-to-curve algorithms as they are gas-expensive to compute onchain func MapToCurve(digest [32]byte) *bn254.G1Affine { one := new(big.Int).SetUint64(1)