arnaucube
arnaucube/gnark-plonky2-verifierPublic Self-hosted repository
gnark-plonky2-verifier/sha512/shift.go
sha512/shift.goRaw
 1package sha512
 2
 3import (
 4	"github.com/consensys/gnark/frontend"
 5)
 6
 7func ShR512(api frontend.API, in []frontend.Variable, r int) ([]frontend.Variable) {
 8	n := len(in)
 9	out := make([] frontend.Variable, n)
10	for i := 0; i < n; i++ {
11		if i+r >= n {
12			out[i] = 0
13		} else {
14			out[i] = in[i+r]
15		}
16	}
17	return out
18}
19
20
21// template ShR512(n, r) {
22//     signal input in[n];
23//     signal output out[n];
24
25//     for (var i=0; i<n; i++) {
26//         if (i+r >= n) {
27//             out[i] <== 0;
28//         } else {
29//             out[i] <== in[ i+r ];
30//         }
31//     }
32// }