diff --git a/docs/modules/ROOT/pages/accounts.adoc b/docs/modules/ROOT/pages/accounts.adoc index b1191be21..1f81d10bc 100644 --- a/docs/modules/ROOT/pages/accounts.adoc +++ b/docs/modules/ROOT/pages/accounts.adoc @@ -523,4 +523,4 @@ const tx = await erc20.transfer( transferCall.calldata, { maxFee: 900_000_000_000_000 } ); await provider.waitForTransaction(tx.transaction_hash); -``` +``` \ No newline at end of file diff --git a/docs/modules/ROOT/pages/api/account.adoc b/docs/modules/ROOT/pages/api/account.adoc index 150467c42..7d18345a8 100644 --- a/docs/modules/ROOT/pages/api/account.adoc +++ b/docs/modules/ROOT/pages/api/account.adoc @@ -823,3 +823,77 @@ Requirements: - The caller is the account contract itself. - `new_class_hash` cannot be zero. + +== Utilities + +These utility modules support signature validation and secp256 elliptic curve operations for account implementations. + +=== secp256_point + +Import path: +[,cairo] +---- +use openzeppelin_account::utils::secp256_point; +---- + +Utilities for handling secp256 curve points, including packing, unpacking, equality checks, and debugging. + +==== Functions + +- `pack(value: Secp256Point) -> (felt252, felt252)` + Packs a secp256 point into two felts for storage. + +- `unpack(value: (felt252, felt252)) -> Secp256Point` + Unpacks two felts into a secp256 point using x-coordinate and parity. + +- `eq(lhs: @Secp256Point, rhs: @Secp256Point) -> bool` + Compares two secp256 points by coordinates. + +- `fmt(self: @Secp256Point, ref f: Formatter)` + Formats the point for human-readable debugging output. + +--- + +=== signature + +Import path: +[,cairo] +---- +use openzeppelin_account::utils::signature; +---- + +Provides helpers for signature verification using secp256k1 (Ethereum), P-256, and Stark signatures. + +WARNING: These functions assume `s` is positive for efficiency and are not safe against malleability attacks outside transaction validation. + +==== Structs + +- `Secp256Signature` + Represents an ECDSA signature with `r` and `s` values. + +==== Functions + +- `is_valid_stark_signature(msg_hash, public_key, signature) -> bool` + Verifies a Stark-compatible ECDSA signature. + +- `is_valid_eth_signature(msg_hash, public_key: EthPublicKey, signature) -> bool` + Verifies a secp256k1 signature over a hash using an Ethereum public key. + +- `is_valid_p256_signature(msg_hash, public_key: P256PublicKey, signature) -> bool` + Verifies a P-256 signature over a hash using a P-256 public key. + +--- + +=== utils + +Import path: +[,cairo] +---- +use openzeppelin_account::utils; +---- + +Re-exports `signature` helpers for convenience. + +Functionality is identical to `utils::signature`. + +--- \ No newline at end of file