From 1d4e378374195c590831e453b071cb7b2c922328 Mon Sep 17 00:00:00 2001 From: Jordan Solomon Date: Wed, 9 Jul 2025 12:09:18 +0100 Subject: [PATCH 1/2] WIP: Documentation changes --- docs/modules/ROOT/pages/accounts.adoc | 74 +++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/docs/modules/ROOT/pages/accounts.adoc b/docs/modules/ROOT/pages/accounts.adoc index b1191be21..9a9fba133 100644 --- a/docs/modules/ROOT/pages/accounts.adoc +++ b/docs/modules/ROOT/pages/accounts.adoc @@ -524,3 +524,77 @@ const tx = await erc20.transfer( ); await provider.waitForTransaction(tx.transaction_hash); ``` + +== Account 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 From 935b02110cebf186d2c105198a97cb66f6513321 Mon Sep 17 00:00:00 2001 From: Jordan Solomon Date: Fri, 11 Jul 2025 11:02:05 +0100 Subject: [PATCH 2/2] moving location of utilities docs to the api ref sec --- docs/modules/ROOT/pages/accounts.adoc | 76 +----------------------- docs/modules/ROOT/pages/api/account.adoc | 74 +++++++++++++++++++++++ 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/docs/modules/ROOT/pages/accounts.adoc b/docs/modules/ROOT/pages/accounts.adoc index 9a9fba133..1f81d10bc 100644 --- a/docs/modules/ROOT/pages/accounts.adoc +++ b/docs/modules/ROOT/pages/accounts.adoc @@ -523,78 +523,4 @@ const tx = await erc20.transfer( transferCall.calldata, { maxFee: 900_000_000_000_000 } ); await provider.waitForTransaction(tx.transaction_hash); -``` - -== Account 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 +``` \ 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