Skip to content

Commit d2dd018

Browse files
committed
Merge branch 'feat/cloak' into HEAD
2 parents 3b40a6b + f17c273 commit d2dd018

File tree

26 files changed

+517
-148
lines changed

26 files changed

+517
-148
lines changed

Cargo.lock

Lines changed: 178 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ repository = "https://github.com/scroll-tech/scroll"
1717
version = "4.5.47"
1818

1919
[workspace.dependencies]
20-
scroll-zkvm-prover = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "060be4c" }
21-
scroll-zkvm-verifier = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "060be4c" }
22-
scroll-zkvm-types = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "060be4c" }
20+
scroll-zkvm-prover = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "aa935df" }
21+
scroll-zkvm-verifier = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "aa935df" }
22+
scroll-zkvm-types = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "aa935df" }
2323

2424
sbv-primitives = { git = "https://github.com/scroll-tech/stateless-block-verifier", branch = "master", features = ["scroll", "rkyv"] }
2525
sbv-utils = { git = "https://github.com/scroll-tech/stateless-block-verifier", branch = "master" }

common/types/message/message.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const (
3939

4040
// ChunkTaskDetail is a type containing ChunkTask detail for chunk task.
4141
type ChunkTaskDetail struct {
42+
Version uint8 `json:"version"`
4243
// use one of the string of "euclidv1" / "euclidv2"
4344
ForkName string `json:"fork_name"`
4445
BlockHashes []common.Hash `json:"block_hashes"`
@@ -90,6 +91,7 @@ func (e *Byte48) UnmarshalJSON(input []byte) error {
9091

9192
// BatchTaskDetail is a type containing BatchTask detail.
9293
type BatchTaskDetail struct {
94+
Version uint8 `json:"version"`
9395
// use one of the string of "euclidv1" / "euclidv2"
9496
ForkName string `json:"fork_name"`
9597
ChunkInfos []*ChunkInfo `json:"chunk_infos"`
@@ -103,6 +105,7 @@ type BatchTaskDetail struct {
103105

104106
// BundleTaskDetail consists of all the information required to describe the task to generate a proof for a bundle of batches.
105107
type BundleTaskDetail struct {
108+
Version uint8 `json:"version"`
106109
// use one of the string of "euclidv1" / "euclidv2"
107110
ForkName string `json:"fork_name"`
108111
BatchProofs []*OpenVMBatchProof `json:"batch_proofs"`
@@ -124,6 +127,9 @@ type ChunkInfo struct {
124127
TxDataLength uint64 `json:"tx_data_length"`
125128
InitialBlockNumber uint64 `json:"initial_block_number"`
126129
BlockCtxs []BlockContextV2 `json:"block_ctxs"`
130+
PrevBlockhash common.Hash `json:"prev_blockhash"`
131+
PostBlockhash common.Hash `json:"post_blockhash"`
132+
EncryptionKey []byte `json:"encryption_key"`
127133
}
128134

129135
// BlockContextV2 is the block context for euclid v2
@@ -186,6 +192,7 @@ type OpenVMBatchInfo struct {
186192
ChainID uint64 `json:"chain_id"`
187193
PrevMsgQueueHash common.Hash `json:"prev_msg_queue_hash"`
188194
PostMsgQueueHash common.Hash `json:"post_msg_queue_hash"`
195+
EncryptionKey []byte `json:"encryption_key"`
189196
}
190197

191198
// BatchProof includes the proof info that are required for batch verification and rollup.
@@ -246,6 +253,7 @@ type OpenVMBundleInfo struct {
246253
PrevBatchHash common.Hash `json:"prev_batch_hash"`
247254
BatchHash common.Hash `json:"batch_hash"`
248255
MsgQueueHash common.Hash `json:"msg_queue_hash"`
256+
EncryptionKey []byte `json:"encryption_key"`
249257
}
250258

251259
// OpenVMBundleProof includes the proof info that are required for verification of a bundle of batch proofs.

coordinator/conf/config.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{
1313
"assets_path": "assets",
1414
"fork_name": "euclidV2"
15-
},
15+
},
1616
{
1717
"assets_path": "assets",
1818
"fork_name": "feynman"
@@ -27,6 +27,7 @@
2727
"maxIdleNum": 20
2828
},
2929
"l2": {
30+
"validium_mode": false,
3031
"chain_id": 111,
3132
"l2geth": {
3233
"endpoint": "not need to specified for mocking"
@@ -36,5 +37,8 @@
3637
"secret": "prover secret key",
3738
"challenge_expire_duration_sec": 3600,
3839
"login_expire_duration_sec": 3600
40+
},
41+
"sequencer": {
42+
"decryption_key": "sequencer decryption key"
3943
}
4044
}

coordinator/internal/config/config.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ type L2Endpoint struct {
3636
// L2 loads l2geth configuration items.
3737
type L2 struct {
3838
// l2geth chain_id.
39-
ChainID uint64 `json:"chain_id"`
40-
Endpoint *L2Endpoint `json:"l2geth"`
39+
ChainID uint64 `json:"chain_id"`
40+
Endpoint *L2Endpoint `json:"l2geth"`
41+
ValidiumMode bool `json:"validium_mode"`
4142
}
4243

4344
// Auth provides the auth coordinator
@@ -47,12 +48,18 @@ type Auth struct {
4748
LoginExpireDurationSec int `json:"login_expire_duration_sec"`
4849
}
4950

51+
// The sequencer controlled data
52+
type Sequencer struct {
53+
DecryptionKey string `json:"decryption_key"`
54+
}
55+
5056
// Config load configuration items.
5157
type Config struct {
5258
ProverManager *ProverManager `json:"prover_manager"`
5359
DB *database.Config `json:"db"`
5460
L2 *L2 `json:"l2"`
5561
Auth *Auth `json:"auth"`
62+
Sequencer *Sequencer `json:"sequencer"`
5663
}
5764

5865
// AssetConfig contain assets configurated for each fork, the defaul vkfile name is "OpenVmVk.json".

coordinator/internal/config/config_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ func TestConfig(t *testing.T) {
3535
"maxIdleNum": 20
3636
},
3737
"l2": {
38-
"chain_id": 111
38+
"chain_id": 111,
39+
"validium_mode": false
3940
},
4041
"auth": {
4142
"secret": "prover secret key",
4243
"challenge_expire_duration_sec": 3600,
4344
"login_expire_duration_sec": 3600
44-
}
45+
},
46+
"sequencer": {
47+
"decryption_key": "sequencer decryption key"
48+
}
4549
}`
4650

4751
t.Run("Success Case", func(t *testing.T) {

coordinator/internal/logic/libzkp/lib.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ func fromMessageTaskType(taskType int) int {
9393
}
9494

9595
// Generate a universal task
96-
func GenerateUniversalTask(taskType int, taskJSON, forkName string, expectedVk []byte) (bool, string, string, []byte) {
97-
return generateUniversalTask(fromMessageTaskType(taskType), taskJSON, strings.ToLower(forkName), expectedVk)
96+
func GenerateUniversalTask(taskType int, taskJSON, forkName string, expectedVk []byte, decryptionKey []byte) (bool, string, string, []byte) {
97+
return generateUniversalTask(fromMessageTaskType(taskType), taskJSON, strings.ToLower(forkName), expectedVk, decryptionKey)
9898
}
9999

100100
// Generate wrapped proof

coordinator/internal/logic/libzkp/libzkp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ HandlingResult gen_universal_task(
4040
char* task,
4141
char* fork_name,
4242
const unsigned char* expected_vk,
43-
size_t expected_vk_len
43+
size_t expected_vk_len,
44+
const unsigned char* decryption_key,
45+
size_t decryption_key_len
4446
);
4547

4648
// Release memory allocated for a HandlingResult returned by gen_universal_task

coordinator/internal/logic/libzkp/mock_universal_task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
func InitL2geth(configJSON string) {
1515
}
1616

17-
func generateUniversalTask(taskType int, taskJSON, forkName string, expectedVk []byte) (bool, string, string, []byte) {
17+
func generateUniversalTask(taskType int, taskJSON, forkName string, expectedVk []byte, decryptionKey []byte) (bool, string, string, []byte) {
1818

1919
fmt.Printf("call mocked generate universal task %d, taskJson %s\n", taskType, taskJSON)
2020
var metadata interface{}

coordinator/internal/logic/libzkp/universal_task.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func InitL2geth(configJSON string) {
1717
C.init_l2geth(cConfig)
1818
}
1919

20-
func generateUniversalTask(taskType int, taskJSON, forkName string, expectedVk []byte) (bool, string, string, []byte) {
20+
func generateUniversalTask(taskType int, taskJSON, forkName string, expectedVk []byte, decryptionKey []byte) (bool, string, string, []byte) {
2121
cTask := goToCString(taskJSON)
2222
cForkName := goToCString(forkName)
2323
defer freeCString(cTask)
@@ -29,7 +29,13 @@ func generateUniversalTask(taskType int, taskJSON, forkName string, expectedVk [
2929
cVk = (*C.uchar)(unsafe.Pointer(&expectedVk[0]))
3030
}
3131

32-
result := C.gen_universal_task(C.int(taskType), cTask, cForkName, cVk, C.size_t(len(expectedVk)))
32+
// Create a C array from Go slice
33+
var cDk *C.uchar
34+
if len(decryptionKey) > 0 {
35+
cDk = (*C.uchar)(unsafe.Pointer(&decryptionKey[0]))
36+
}
37+
38+
result := C.gen_universal_task(C.int(taskType), cTask, cForkName, cVk, C.size_t(len(expectedVk)), cDk, C.size_t(len(decryptionKey)))
3339
defer C.release_task_result(result)
3440

3541
// Check if the operation was successful

0 commit comments

Comments
 (0)