From 7178382544092bbdb5e4feaefccdf5340d2f76fb Mon Sep 17 00:00:00 2001 From: DC Date: Tue, 30 Jul 2024 13:15:51 -0700 Subject: [PATCH] N-02: make state variables private --- src/P256.sol | 5 +++-- src/P256Verifier.sol | 16 ++++++++-------- src/WebAuthn.sol | 8 ++++---- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/P256.sol b/src/P256.sol index d7d1617..831850e 100644 --- a/src/P256.sol +++ b/src/P256.sol @@ -8,8 +8,9 @@ pragma solidity 0.8.21; * @custom:security-contact security@daimo.com **/ library P256 { - address constant PRECOMPILE = address(0x100); - address constant VERIFIER = 0xc2b78104907F722DABAc4C69f826a522B2754De4; + address public constant PRECOMPILE = address(0x100); + address public constant VERIFIER = + 0xc2b78104907F722DABAc4C69f826a522B2754De4; function verifySignatureAllowMalleability( bytes32 message_hash, diff --git a/src/P256Verifier.sol b/src/P256Verifier.sol index 302851e..e0bde14 100644 --- a/src/P256Verifier.sol +++ b/src/P256Verifier.sol @@ -42,27 +42,27 @@ contract P256Verifier { // Parameters for the sec256r1 (P256) elliptic curve // Curve prime field modulus - uint256 constant p = + uint256 private constant p = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF; // Short weierstrass first coefficient - uint256 constant a = // The assumption a == -3 (mod p) is used throughout the codebase + uint256 private constant a = // The assumption a == -3 (mod p) is used throughout the codebase 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC; // Short weierstrass second coefficient - uint256 constant b = + uint256 private constant b = 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B; // Generating point affine coordinates - uint256 constant GX = + uint256 private constant GX = 0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296; - uint256 constant GY = + uint256 private constant GY = 0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5; // Curve order (number of points) - uint256 constant n = + uint256 private constant n = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551; // -2 mod p constant, used to speed up inversion and doubling (avoid negation) - uint256 constant minus_2modp = + uint256 private constant minus_2modp = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFD; // -2 mod n constant, used to speed up inversion - uint256 constant minus_2modn = + uint256 private constant minus_2modn = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC63254F; /** diff --git a/src/WebAuthn.sol b/src/WebAuthn.sol index 42f2014..079ce44 100644 --- a/src/WebAuthn.sol +++ b/src/WebAuthn.sol @@ -33,10 +33,10 @@ library WebAuthn { return true; } - bytes1 constant AUTH_DATA_FLAGS_UP = 0x01; // Bit 0 - bytes1 constant AUTH_DATA_FLAGS_UV = 0x04; // Bit 2 - bytes1 constant AUTH_DATA_FLAGS_BE = 0x08; // Bit 3 - bytes1 constant AUTH_DATA_FLAGS_BS = 0x10; // Bit 4 + bytes1 private constant AUTH_DATA_FLAGS_UP = 0x01; // Bit 0 + bytes1 private constant AUTH_DATA_FLAGS_UV = 0x04; // Bit 2 + bytes1 private constant AUTH_DATA_FLAGS_BE = 0x08; // Bit 3 + bytes1 private constant AUTH_DATA_FLAGS_BS = 0x10; // Bit 4 /// Verifies the authFlags in authenticatorData. Numbers in inline comment /// correspond to the same numbered bullets in