Skip to content

Commit

Permalink
some updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mimoo committed Dec 21, 2023
1 parent d66d09b commit d029ee5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/starkex/cairo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Verifying a SHARP Cairo proof on the Starkex contracts is done in a number of transactions:

* 3 Verify Merkle transactions ([example](https://etherscan.io/tx/0x5ad19d4524e0d2f2281dd71b8b1030fca7131ce74b821b936f73df2cba9d65e5))
* 8 Verify FRI transactions ([example](https://etherscan.io/tx/0xccc7446d9e5e14892496ee3956f0e9579c2f56b8e70441623aa283c302130201))
* A bunch of Register Continuous Memory Page ([example](https://etherscan.io/tx/0x6862ef5e0ce7599124e7c81625130990a102f483dde292d76b8d869b7d280ea7))
* 3 [Verify Merkle](https://etherscan.io/address/0x5899efea757e0dbd6d114b3375c23d7540f65fa4) transactions to verify Merkle paths ([example](https://etherscan.io/tx/0x5ad19d4524e0d2f2281dd71b8b1030fca7131ce74b821b936f73df2cba9d65e5))
* 8 [Verify FRI](https://etherscan.io/address/0x3e6118da317f7a433031f03bb71ab870d87dd2dd) transactions to verify the FRI proofs ([example](https://etherscan.io/tx/0xccc7446d9e5e14892496ee3956f0e9579c2f56b8e70441623aa283c302130201))
* A bunch of [Register Continuous Memory Page](https://etherscan.io/address/0xfd14567eaf9ba941cb8c8a94eec14831ca7fd1b4) transactions ([example](https://etherscan.io/tx/0x6862ef5e0ce7599124e7c81625130990a102f483dde292d76b8d869b7d280ea7))
* A single Verify Proof and Register ([example](https://etherscan.io/tx/0x720571bcac39e6b973537d7dd2ba253072e6f82c634ce361de73769d026ce4a1))

The reason the verification of a proof is split in multiple transactions is because proofs are too large, and the verification cost too much gas, to fit in a single transaction.
Expand Down
31 changes: 29 additions & 2 deletions src/starkex/facts.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ where `registerGpsFacts` is defined as:
## Example of checking if a fact is registered
[Starknet]() is one user of SHARP, and as such their smart contract uses the fact registry.
[Starknet](https://book.starknet.io/) is the main application making use of SHARP, and as such their smart contract uses the fact registry directly.
The main function of Starknet is [`updateState()`](https://github.com/mimoo/starknet-contracts/blob/main/contracts/Starknet.sol#L176) which updates the state based on proofs that have been verified:
The main function of Starknet is [`updateState()`](https://github.com/mimoo/starknet-contracts/blob/main/contracts/Starknet.sol#L176), which updates the state based on proofs that have been verified:
```js
function updateState(
Expand All @@ -103,4 +103,31 @@ The main function of Starknet is [`updateState()`](https://github.com/mimoo/star
);

// TRUNCATED...
```
Another example we can look at is within a proof verification. As explained in [Verifying a Cairo proof](./cairo.md), a proof verification is split in multiple transactions.
For example, Merkle membership proofs are verified in segregated transactions, and then the fact that they were verified is used within another execution:
```js
function verifyMerkle(
uint256[] memory merkleView,
uint256[] memory initialMerkleQueue,
uint256 height,
uint256 expectedRoot
) public {
// TRUNCATED...

bytes32 resRoot = verifyMerkle(channelPtr, merkleQueuePtr, bytes32(expectedRoot), nQueries);
bytes32 factHash;
assembly {
// Append the resulted root (should be the return value of verify) to dataToHashPtr.
mstore(dataToHashPtr, resRoot)
// Reset dataToHashPtr.
dataToHashPtr := add(channelPtr, 0x20)
factHash := keccak256(dataToHashPtr, add(mul(nQueries, 0x40), 0x20))
}

registerFact(factHash);
}
```
5 changes: 4 additions & 1 deletion src/starkex/starkex.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Starkex

The starkex contract live in https://github.com/starkware-libs/starkex-contracts
The starkex contracts are deployed at [0x6cB3EE90C50a38A0e4662bB7e7E6e40B91361BF6](https://etherscan.io/address/0x6cB3EE90C50a38A0e4662bB7e7E6e40B91361BF6#code) and sit behind the upgradable smart contract at [0x47312450b3ac8b5b8e247a6bb6d523e7605bdb60](https://etherscan.io/address/0x47312450b3ac8b5b8e247a6bb6d523e7605bdb60#readProxyContract).

Somewhat outdated implementations live on Github at [starkware-libs/starkex-contracts](https://github.com/starkware-libs/starkex-contracts).

They implement the [SHARP (SHARed Prover)](https://starkware.co/resource/joining-forces-sharp/) verifier, which allows us to verify SHARP proofs on Ethereum.

> Note: A number of contracts refer to "GPS" which is the old name for SHARP (general-proving service).
Expand Down

0 comments on commit d029ee5

Please sign in to comment.