Longfellow ZK 0290cb32
Loading...
Searching...
No Matches
ligero_transcript.h
1// Copyright 2025 Google LLC.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef PRIVACY_PROOFS_ZK_LIB_LIGERO_LIGERO_TRANSCRIPT_H_
16#define PRIVACY_PROOFS_ZK_LIB_LIGERO_LIGERO_TRANSCRIPT_H_
17
18#include <stddef.h>
19
20#include <array>
21
22#include "ligero/ligero_param.h"
23#include "random/transcript.h"
24
25namespace proofs {
26template <class Field>
28 public:
29 using Elt = typename Field::Elt;
30
31 static void write_commitment(const LigeroCommitment<Field>& commitment,
32 Transcript& ts) {
33 ts.write(commitment.root.data, commitment.root.kLength);
34 }
35
36 static void gen_uldt(Elt u[/*nwqrow*/], const LigeroParam<Field>& p,
37 Transcript& ts, const Field& F) {
38 ts.elt(u, p.nwqrow, F);
39 }
40
41 static void gen_alphal(size_t nl, Elt alpha[/*nl*/], Transcript& ts,
42 const Field& F) {
43 ts.elt(alpha, nl, F);
44 }
45
46 static void gen_alphaq(std::array<Elt, 3> alpha[/*nq*/],
47 const LigeroParam<Field>& p, Transcript& ts,
48 const Field& F) {
49 ts.elt(&alpha[0][0], 3 * p.nq, F);
50 }
51
52 static void gen_uquad(Elt u[/*nqtriples*/], const LigeroParam<Field>& p,
53 Transcript& ts, const Field& F) {
54 ts.elt(u, p.nqtriples, F);
55 }
56
57 // Choose p.nreq distinct naturals in [0, p.block_enc - p.dblock)
58 static void gen_idx(size_t idx[/*p.nreq*/], const LigeroParam<Field>& p,
59 Transcript& ts, const Field& F) {
60 check(p.block_enc >= p.dblock, "p.block_enc >= p.dblock");
61 check(p.block_enc - p.dblock >= p.nreq, "p.block_enc - p.dblock >= p.nreq");
62 ts.choose(idx, p.block_enc - p.dblock, p.nreq);
63 }
64};
65} // namespace proofs
66
67#endif // PRIVACY_PROOFS_ZK_LIB_LIGERO_LIGERO_TRANSCRIPT_H_
Definition ligero_transcript.h:27
Definition transcript.h:65
Definition gf2_128.h:63
Definition ligero_param.h:294
Definition ligero_param.h:117