Skip to content

Encoding of ark_secp256r1 Scalars must be big-endian #78

@armfazh

Description

@armfazh

The NargSerialize trait stipulates that the encoding of field elements must follow I2OSP (big-endian).

However, the implementation for ark_ff objects was done using little-endian.

This script shows the mismatch.

use spongefish::Encoding;
type ArkP256Scalar = <ark_secp256r1::Projective as ark_ec::PrimeGroup>::ScalarField;
let ark_scalar = ArkP256Scalar::from(18u64);
let encoded = ark_scalar.encode();
let big_endian = [vec![0u8; 31], vec![18]].concat();
assert_eq!(encoded.as_ref(), big_endian, "mismatch endianess")

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