aboutsummaryrefslogtreecommitdiff
path: root/nizk/commit.go
diff options
context:
space:
mode:
authorÖzgür Kesim <oec@codeblau.de>2024-11-15 19:30:11 +0100
committerÖzgür Kesim <oec@codeblau.de>2024-11-15 19:30:11 +0100
commit9dbeb486bae03555c0ebd8e30708ef1fb2132231 (patch)
tree8a18b5e650d3bfa4568f81331cd21419ea172109 /nizk/commit.go
parent0eab6394734540c31dad54ecfc691b790ea4550c (diff)
randomized test and benchmark work!
Diffstat (limited to 'nizk/commit.go')
-rw-r--r--nizk/commit.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/nizk/commit.go b/nizk/commit.go
index 93c730f..27e31f7 100644
--- a/nizk/commit.go
+++ b/nizk/commit.go
@@ -55,6 +55,18 @@ func NewBitFromScalars(id Bytes, set bool, α, β *Scalar) *Bit {
return b
}
+func Int2Bits(id Bytes, val int, bitlength int) []*Bit {
+ if bitlength < 0 || bitlength > 24 {
+ return nil
+ }
+
+ bits := make([]*Bit, bitlength)
+ for i := range bitlength {
+ bits[i] = NewBit(id, (val>>(bitlength-i-1))&1 != 0)
+ }
+ return bits
+}
+
func (b *Bit) IsSet() bool {
return b.set
}