diff --git a/docs/src/README.md b/docs/src/README.md index 739cc36..e8e445e 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -48,15 +48,17 @@ $ anvil ### Deploy ```shell -$ forge script script/PrimusZkTLS.s.sol --rpc-url --private-key --broadcast +$ forge script script/PrimusZKTLS.s.sol --rpc-url --private-key --broadcast ``` ### Upgrade ```shell -$ forge script script/UpgradeZkTLS.s.sol --rpc-url --private-key --broadcast +$ forge script script/UpgradeZKTLS.s.sol --rpc-url --private-key --broadcast + ``` + ### Cast ```shell diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 1335d7c..7164452 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -6,6 +6,4 @@ - [AttNetworkResponseResolve](src/IPrimusZKTLS.sol/struct.AttNetworkResponseResolve.md) - [Attestor](src/IPrimusZKTLS.sol/struct.Attestor.md) - [IPrimusZKTLS](src/IPrimusZKTLS.sol/interface.IPrimusZKTLS.md) - - [AddAttestor](src/PrimusZKTLS.sol/event.AddAttestor.md) - - [DelAttestor](src/PrimusZKTLS.sol/event.DelAttestor.md) - [PrimusZKTLS](src/PrimusZKTLS.sol/contract.PrimusZKTLS.md) diff --git a/docs/src/src/IPrimusZkTLS.sol/interface.IPrimusZkTLS.md b/docs/src/src/IPrimusZkTLS.sol/interface.IPrimusZkTLS.md index 3a99df6..437f775 100644 --- a/docs/src/src/IPrimusZkTLS.sol/interface.IPrimusZkTLS.md +++ b/docs/src/src/IPrimusZkTLS.sol/interface.IPrimusZkTLS.md @@ -1,5 +1,5 @@ # IPrimusZKTLS -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/c34826da72b2646b30fc46afeef78c9dafa36cd0/src/IPrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/IPrimusZKTLS.sol) *Interface of PrimusZKTLS, which defines functions for handling attestations and related operations.* diff --git a/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkRequest.md b/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkRequest.md index c1016c2..92a4d35 100644 --- a/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkRequest.md +++ b/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkRequest.md @@ -1,5 +1,5 @@ # AttNetworkRequest -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/c34826da72b2646b30fc46afeef78c9dafa36cd0/src/IPrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/IPrimusZKTLS.sol) *Structure for representing a network request send to jsk and related to the attestation.* diff --git a/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkResponseResolve.md b/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkResponseResolve.md index 639de25..558fc29 100644 --- a/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkResponseResolve.md +++ b/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkResponseResolve.md @@ -1,5 +1,5 @@ # AttNetworkResponseResolve -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/c34826da72b2646b30fc46afeef78c9dafa36cd0/src/IPrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/IPrimusZKTLS.sol) *Structure for resolving responses from a network request.* diff --git a/docs/src/src/IPrimusZkTLS.sol/struct.Attestation.md b/docs/src/src/IPrimusZkTLS.sol/struct.Attestation.md index 11296c9..fe1a725 100644 --- a/docs/src/src/IPrimusZkTLS.sol/struct.Attestation.md +++ b/docs/src/src/IPrimusZkTLS.sol/struct.Attestation.md @@ -1,5 +1,5 @@ # Attestation -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/c34826da72b2646b30fc46afeef78c9dafa36cd0/src/IPrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/IPrimusZKTLS.sol) *Structure representing an attestation, which is a signed statement of fact.* @@ -8,13 +8,13 @@ struct Attestation { address recipient; AttNetworkRequest request; - AttNetworkResponseResolve[] reponse; + AttNetworkResponseResolve[] reponseResolve; string data; string attConditions; uint64 timestamp; - string attitionParams; + string additionParams; Attestor[] attestors; - bytes[] signature; + bytes[] signatures; } ``` diff --git a/docs/src/src/IPrimusZkTLS.sol/struct.Attestor.md b/docs/src/src/IPrimusZkTLS.sol/struct.Attestor.md index 3a416d3..7a85264 100644 --- a/docs/src/src/IPrimusZkTLS.sol/struct.Attestor.md +++ b/docs/src/src/IPrimusZkTLS.sol/struct.Attestor.md @@ -1,5 +1,5 @@ # Attestor -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/c34826da72b2646b30fc46afeef78c9dafa36cd0/src/IPrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/IPrimusZKTLS.sol) *Structure representing an attestor, who is responsible for signing the attestation.* diff --git a/docs/src/src/PrimusZkTLS.sol/contract.PrimusZkTLS.md b/docs/src/src/PrimusZkTLS.sol/contract.PrimusZkTLS.md index 1082da8..ac47396 100644 --- a/docs/src/src/PrimusZkTLS.sol/contract.PrimusZkTLS.md +++ b/docs/src/src/PrimusZkTLS.sol/contract.PrimusZkTLS.md @@ -1,5 +1,5 @@ # PrimusZKTLS -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/c34826da72b2646b30fc46afeef78c9dafa36cd0/src/PrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/PrimusZKTLS.sol) **Inherits:** OwnableUpgradeable, [IPrimusZKTLS](/src/IPrimusZKTLS.sol/interface.IPrimusZKTLS.md) @@ -165,3 +165,16 @@ function encodeResponse(AttNetworkResponseResolve[] calldata reponse) public pur |``|`bytes32`|A bytes32 hash of the encoded response resolutions.| +## Events +### AddAttestor + +```solidity +event AddAttestor(address _address, Attestor _attestor); +``` + +### DelAttestor + +```solidity +event DelAttestor(address _address); +``` + diff --git a/docs/src/src/README.md b/docs/src/src/README.md index 6f12893..66ce5ca 100644 --- a/docs/src/src/README.md +++ b/docs/src/src/README.md @@ -6,6 +6,4 @@ - [AttNetworkResponseResolve](IPrimusZKTLS.sol/struct.AttNetworkResponseResolve.md) - [Attestor](IPrimusZKTLS.sol/struct.Attestor.md) - [IPrimusZKTLS](IPrimusZKTLS.sol/interface.IPrimusZKTLS.md) -- [AddAttestor](PrimusZKTLS.sol/event.AddAttestor.md) -- [DelAttestor](PrimusZKTLS.sol/event.DelAttestor.md) - [PrimusZKTLS](PrimusZKTLS.sol/contract.PrimusZKTLS.md) diff --git a/src/IPrimusZKTLS.sol b/src/IPrimusZKTLS.sol index c0442da..ac79bd0 100644 --- a/src/IPrimusZKTLS.sol +++ b/src/IPrimusZKTLS.sol @@ -8,13 +8,13 @@ pragma solidity ^0.8.20; struct Attestation { address recipient; // The recipient of the attestation. AttNetworkRequest request; // The network request send to jsk and related to the attestation. - AttNetworkResponseResolve[] reponse; // The response details responsed from jdk. + AttNetworkResponseResolve[] reponseResolve; // The response details responsed from jdk. string data; // Real data in the pending body provided in JSON string format. string attConditions; // Attestation parameters in JSON string format. uint64 timestamp; // The timestamp of when the attestation was created. - string attitionParams; // Extra data for more inormation. + string additionParams; // Extra data for more inormation. Attestor[] attestors; // List of attestors who signed the attestation. - bytes[] signature; // signature from the attestor. + bytes[] signatures; // signature from the attestor. } /** diff --git a/src/PrimusZKTLS.sol b/src/PrimusZKTLS.sol index 36292f8..5db8f66 100644 --- a/src/PrimusZKTLS.sol +++ b/src/PrimusZKTLS.sol @@ -105,8 +105,8 @@ contract PrimusZKTLS is OwnableUpgradeable, IPrimusZKTLS { * @param attestation The attestation data to be verified. */ function verifyAttestation(Attestation calldata attestation) external view { - require(attestation.signature.length == 1, "Invalid signature length"); - bytes memory signature = attestation.signature[0]; + require(attestation.signatures.length == 1, "Invalid signature length"); + bytes memory signature = attestation.signatures[0]; require(signature.length == 65,"Invalid signature length"); bytes32 r; bytes32 s; @@ -144,11 +144,11 @@ contract PrimusZKTLS is OwnableUpgradeable, IPrimusZKTLS { bytes memory encodeData = abi.encodePacked( attestation.recipient, encodeRequest(attestation.request), - encodeResponse(attestation.reponse), + encodeResponse(attestation.reponseResolve), attestation.data, attestation.attConditions, attestation.timestamp, - attestation.attitionParams + attestation.additionParams ); return keccak256(encodeData); } diff --git a/test/PrimusZKTLSTest.t.sol b/test/PrimusZKTLSTest.t.sol index 642ba0c..88fb516 100644 --- a/test/PrimusZKTLSTest.t.sol +++ b/test/PrimusZKTLSTest.t.sol @@ -157,13 +157,13 @@ contract PrimusZKTLSTest is Test { Attestation memory attestation = Attestation({ recipient: address(this), request: request, - reponse: response, + reponseResolve: response, data: bodyString, attConditions: '{"param":"value"}', timestamp: uint64(block.timestamp), - attitionParams: '{"param":"value"}', + additionParams: '{"param":"value"}', attestors: new Attestor[] (1), // List of attestors who signed the attestation. - signature: new bytes[] (1) + signatures: new bytes[] (1) }); //get Gas used for AttestationEncode @@ -191,13 +191,13 @@ contract PrimusZKTLSTest is Test { Attestation memory attestation = Attestation({ recipient: bob, request: request, - reponse: response, + reponseResolve: response, data: bodyString, attConditions: '{"param":"value"}', timestamp: uint64(block.timestamp), - attitionParams: '{"param":"value"}', + additionParams: '{"param":"value"}', attestors: new Attestor[] (1), - signature: new bytes[] (1) + signatures: new bytes[] (1) }); console.log("recipient----address:%s",addressToString(attestation.recipient)); @@ -211,7 +211,7 @@ contract PrimusZKTLSTest is Test { console.log("signature----%s",bytesToHexString(signature)); - attestation.signature[0] = signature; + attestation.signatures[0] = signature; uint256 gasStart = gasleft(); zkTLS.verifyAttestation(attestation);