-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f320f9f
commit 3d3be23
Showing
3 changed files
with
165 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.16; | ||
|
||
import {Secp256k1, PrivateKey, PublicKey} from "src/curves/Secp256k1.sol"; | ||
import { | ||
Secp256k1Arithmetic, | ||
AffinePoint, | ||
JacobianPoint | ||
} from "src/curves/Secp256k1Arithmetic.sol"; | ||
|
||
/** | ||
* @title Secp256k1ArithmeticWrapper | ||
* | ||
* @notice Library wrapper to enable forge coverage reporting | ||
* | ||
* @dev For more info, see https://github.com/foundry-rs/foundry/pull/3128#issuecomment-1241245086. | ||
*/ | ||
contract Secp256k1ArithmeticWrapper { | ||
using Secp256k1Arithmetic for AffinePoint; | ||
using Secp256k1Arithmetic for JacobianPoint; | ||
|
||
//-------------------------------------------------------------------------- | ||
// Constants | ||
|
||
function G() public pure returns (AffinePoint memory) { | ||
return Secp256k1Arithmetic.G(); | ||
} | ||
|
||
//-------------------------------------------------------------------------- | ||
// Affine Point | ||
|
||
function ZeroPoint() public pure returns (AffinePoint memory) { | ||
return Secp256k1Arithmetic.ZeroPoint(); | ||
} | ||
|
||
function isZeroPoint(AffinePoint memory point) public pure returns (bool) { | ||
return point.isZeroPoint(); | ||
} | ||
|
||
function PointAtInfinity() public pure returns (AffinePoint memory) { | ||
return Secp256k1Arithmetic.PointAtInfinity(); | ||
} | ||
|
||
function isPointAtInfinity(AffinePoint memory point) | ||
public | ||
pure | ||
returns (bool) | ||
{ | ||
return point.isPointAtInfinity(); | ||
} | ||
|
||
function isOnCurve(AffinePoint memory point) public pure returns (bool) { | ||
return point.isOnCurve(); | ||
} | ||
|
||
function yParity(AffinePoint memory point) public pure returns (uint) { | ||
return point.yParity(); | ||
} | ||
|
||
//-------------------------------------------------------------------------- | ||
// (De)Serialization | ||
|
||
//---------------------------------- | ||
// Affine Point | ||
|
||
function toJacobianPoint(AffinePoint memory point) | ||
public | ||
pure | ||
returns (JacobianPoint memory) | ||
{ | ||
return point.toJacobianPoint(); | ||
} | ||
|
||
//---------------------------------- | ||
// Jacobian Point | ||
|
||
function intoAffinePoint(JacobianPoint memory jacPoint) | ||
public | ||
pure | ||
returns (AffinePoint memory) | ||
{ | ||
return jacPoint.intoAffinePoint(); | ||
} | ||
|
||
//-------------------------------------------------------------------------- | ||
// Utils | ||
|
||
function modularInverseOf(uint x) public pure returns (uint) { | ||
return Secp256k1Arithmetic.modularInverseOf(x); | ||
} | ||
} |