Skip to content

Commit

Permalink
change property name update doc & fix bug in test file
Browse files Browse the repository at this point in the history
  • Loading branch information
WuEcho committed Dec 10, 2024
1 parent 598ebb1 commit cd5251a
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 29 deletions.
6 changes: 4 additions & 2 deletions docs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ $ anvil
### Deploy

```shell
$ forge script script/PrimusZkTLS.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key> --broadcast
$ forge script script/PrimusZKTLS.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key> --broadcast
```

### Upgrade

```shell
$ forge script script/UpgradeZkTLS.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key> --broadcast
$ forge script script/UpgradeZKTLS.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key> --broadcast

```


### Cast

```shell
Expand Down
2 changes: 0 additions & 2 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion docs/src/src/IPrimusZkTLS.sol/interface.IPrimusZkTLS.md
Original file line number Diff line number Diff line change
@@ -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.*

Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkRequest.md
Original file line number Diff line number Diff line change
@@ -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.*

Expand Down
Original file line number Diff line number Diff line change
@@ -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.*

Expand Down
8 changes: 4 additions & 4 deletions docs/src/src/IPrimusZkTLS.sol/struct.Attestation.md
Original file line number Diff line number Diff line change
@@ -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.*

Expand All @@ -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;
}
```

2 changes: 1 addition & 1 deletion docs/src/src/IPrimusZkTLS.sol/struct.Attestor.md
Original file line number Diff line number Diff line change
@@ -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.*

Expand Down
15 changes: 14 additions & 1 deletion docs/src/src/PrimusZkTLS.sol/contract.PrimusZkTLS.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -165,3 +165,16 @@ function encodeResponse(AttNetworkResponseResolve[] calldata reponse) public pur
|`<none>`|`bytes32`|A bytes32 hash of the encoded response resolutions.|


## Events
### AddAttestor

```solidity
event AddAttestor(address _address, Attestor _attestor);
```

### DelAttestor

```solidity
event DelAttestor(address _address);
```

2 changes: 0 additions & 2 deletions docs/src/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions src/IPrimusZKTLS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/PrimusZKTLS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
14 changes: 7 additions & 7 deletions test/PrimusZKTLSTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand Down

0 comments on commit cd5251a

Please sign in to comment.