feat: 添加 Lighter 适配器及相关功能,支持 trailing stops 和新的交易逻辑

This commit is contained in:
discountry
2025-09-30 22:08:05 +08:00
parent e83bdfccf9
commit c8b0ab1c8e
101 changed files with 90621 additions and 3 deletions
@@ -0,0 +1,174 @@
package poseidon2_plonky2
import g "github.com/elliottech/poseidon_crypto/field/goldilocks"
const (
WIDTH = 12
RATE = 8
OUT = 4
D = 7
// Generated by `poseidon2_round_numbers_128`
ROUNDS_F = 8
ROUNDS_F_HALF = 4
ROUNDS_P = 22
)
var (
// Generated randomly for ROUNDS_F
EXTERNAL_CONSTANTS = [ROUNDS_F][WIDTH]g.GoldilocksField{
{
15492826721047263190,
11728330187201910315,
8836021247773420868,
16777404051263952451,
5510875212538051896,
6173089941271892285,
2927757366422211339,
10340958981325008808,
8541987352684552425,
9739599543776434497,
15073950188101532019,
12084856431752384512,
},
{
4584713381960671270,
8807052963476652830,
54136601502601741,
4872702333905478703,
5551030319979516287,
12889366755535460989,
16329242193178844328,
412018088475211848,
10505784623379650541,
9758812378619434837,
7421979329386275117,
375240370024755551,
},
{
3331431125640721931,
15684937309956309981,
578521833432107983,
14379242000670861838,
17922409828154900976,
8153494278429192257,
15904673920630731971,
11217863998460634216,
3301540195510742136,
9937973023749922003,
3059102938155026419,
1895288289490976132,
},
{
5580912693628927540,
10064804080494788323,
9582481583369602410,
10186259561546797986,
247426333829703916,
13193193905461376067,
6386232593701758044,
17954717245501896472,
1531720443376282699,
2455761864255501970,
11234429217864304495,
4746959618548874102,
},
{
13571697342473846203,
17477857865056504753,
15963032953523553760,
16033593225279635898,
14252634232868282405,
8219748254835277737,
7459165569491914711,
15855939513193752003,
16788866461340278896,
7102224659693946577,
3024718005636976471,
13695468978618890430,
},
{
8214202050877825436,
2670727992739346204,
16259532062589659211,
11869922396257088411,
3179482916972760137,
13525476046633427808,
3217337278042947412,
14494689598654046340,
15837379330312175383,
8029037639801151344,
2153456285263517937,
8301106462311849241,
},
{
13294194396455217955,
17394768489610594315,
12847609130464867455,
14015739446356528640,
5879251655839607853,
9747000124977436185,
8950393546890284269,
10765765936405694368,
14695323910334139959,
16366254691123000864,
15292774414889043182,
10910394433429313384,
},
{
17253424460214596184,
3442854447664030446,
3005570425335613727,
10859158614900201063,
9763230642109343539,
6647722546511515039,
909012944955815706,
18101204076790399111,
11588128829349125809,
15863878496612806566,
5201119062417750399,
176665553780565743,
},
}
// Generated randomly for ROUNDS_P
INTERNAL_CONSTANTS = [ROUNDS_P]g.GoldilocksField{
11921381764981422944,
10318423381711320787,
8291411502347000766,
229948027109387563,
9152521390190983261,
7129306032690285515,
15395989607365232011,
8641397269074305925,
17256848792241043600,
6046475228902245682,
12041608676381094092,
12785542378683951657,
14546032085337914034,
3304199118235116851,
16499627707072547655,
10386478025625759321,
13475579315436919170,
16042710511297532028,
1411266850385657080,
9024840976168649958,
14047056970978379368,
838728605080212101,
}
// Taken from Plonk3 Poseidon2 implementation. https://github.com/Plonky3/Plonky3/blob/eeb4e37b20127c4daa871b2bad0df30a7c7380db/goldilocks/src/poseidon2.rs#L28
MATRIX_DIAG_12_U64 = [WIDTH]g.GoldilocksField{
0xc3b6c08e23ba9300,
0xd84b5de94a324fb6,
0x0d0c371c5b35b84f,
0x7964f570e7188037,
0x5daf18bbd996604b,
0x6743bc47b9595257,
0x5528b9362c59bb70,
0xac45e25b7127b68b,
0xa2077d7dfbb606b5,
0xf3faac6faee378ae,
0x0c6388b51545e883,
0xd27dbb6944917b60,
}
)