Skip to content
This repository was archived by the owner on Sep 8, 2022. It is now read-only.

Commit ada6d94

Browse files
authored
Merge pull request #24 from mikelodder7/master
2 parents a0c1a76 + 5814a92 commit ada6d94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+418
-115
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to this repo will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## v1.5.4
9+
- Export Value in ElGamal Public Keys
10+
811
## v1.5.3
912
- Address Alpha-Rays attack on GG20 DKG https://eprint.iacr.org/2021/1621.pdf
1013

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM golang:1.17 AS builder
2+
# Install gomarkdoc
3+
RUN GO111MODULE=on go get -u github.com/princjef/gomarkdoc/cmd/gomarkdoc
4+
5+
# Install rust and build spdx
6+
COPY . /kryptology
7+
WORKDIR /kryptology
8+
9+
RUN apt update && apt install -y curl
10+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -- | sh -s -- -y
11+
RUN /root/.cargo/bin/cargo build --release --manifest-path=./cmd/spdx/Cargo.toml && \
12+
cp ./cmd/spdx/target/release/spdx /usr/bin/ && \
13+
chmod 755 /usr/bin/spdx

pkg/core/curves/native/bls12-381/arithmetic_decl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44
// SPDX-License-Identifier: Apache-2.0
55
//
6-
6+
//go:build amd64 && !generic
77
// +build amd64,!generic
88

99
package bls12381

pkg/core/curves/native/bls12-381/arithmetic_fallback.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/dkg/frost/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import "github.com/coinbase/kryptology/pkg/dkg/frost"
1414
- [func (dp *DkgParticipant) Round2(bcast map[uint32]*Round1Bcast, p2psend map[uint32]*sharing.ShamirShare) (*Round2Bcast, error)](<#func-dkgparticipant-round2>)
1515
- [type Round1Bcast](<#type-round1bcast>)
1616
- [type Round1P2PSend](<#type-round1p2psend>)
17+
- [type Round1Result](<#type-round1result>)
18+
- [func (result *Round1Result) Decode(input []byte) error](<#func-round1result-decode>)
19+
- [func (result *Round1Result) Encode() ([]byte, error)](<#func-round1result-encode>)
1720
- [type Round2Bcast](<#type-round2bcast>)
1821

1922

@@ -72,6 +75,27 @@ Round1P2PSend are values that are P2PSend to all other participants after round1
7275
type Round1P2PSend = map[uint32]*sharing.ShamirShare
7376
```
7477

78+
## type [Round1Result](<https://github.com/coinbase/kryptology/blob/master/pkg/dkg/frost/dkg_round1.go#L28-L31>)
79+
80+
```go
81+
type Round1Result struct {
82+
Broadcast *Round1Bcast
83+
P2P *sharing.ShamirShare
84+
}
85+
```
86+
87+
### func \(\*Round1Result\) [Decode](<https://github.com/coinbase/kryptology/blob/master/pkg/dkg/frost/dkg_round1.go#L44>)
88+
89+
```go
90+
func (result *Round1Result) Decode(input []byte) error
91+
```
92+
93+
### func \(\*Round1Result\) [Encode](<https://github.com/coinbase/kryptology/blob/master/pkg/dkg/frost/dkg_round1.go#L33>)
94+
95+
```go
96+
func (result *Round1Result) Encode() ([]byte, error)
97+
```
98+
7599
## type [Round2Bcast](<https://github.com/coinbase/kryptology/blob/master/pkg/dkg/frost/dkg_round2.go#L18-L21>)
76100

77101
Round2Bcast are values that are broadcast to all other participants after round2 completes

pkg/dkg/frost/dkg_round1.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
package frost
88

99
import (
10+
"bytes"
1011
crand "crypto/rand"
12+
"encoding/gob"
1113
"fmt"
1214
"github.com/coinbase/kryptology/internal"
1315
"github.com/coinbase/kryptology/pkg/core/curves"
1416
"github.com/coinbase/kryptology/pkg/sharing"
17+
"github.com/pkg/errors"
1518
"reflect"
1619
)
1720

@@ -22,6 +25,31 @@ type Round1Bcast struct {
2225
Wi, Ci curves.Scalar
2326
}
2427

28+
type Round1Result struct {
29+
Broadcast *Round1Bcast
30+
P2P *sharing.ShamirShare
31+
}
32+
33+
func (result *Round1Result) Encode() ([]byte, error) {
34+
gob.Register(result.Broadcast.Verifiers.Commitments[0]) // just the point for now
35+
gob.Register(result.Broadcast.Ci)
36+
buf := &bytes.Buffer{}
37+
enc := gob.NewEncoder(buf)
38+
if err := enc.Encode(result); err != nil {
39+
return nil, errors.Wrap(err, "couldn't encode round 1 broadcast")
40+
}
41+
return buf.Bytes(), nil
42+
}
43+
44+
func (result *Round1Result) Decode(input []byte) error {
45+
buf := bytes.NewBuffer(input)
46+
dec := gob.NewDecoder(buf)
47+
if err := dec.Decode(result); err != nil {
48+
return errors.Wrap(err, "couldn't encode round 1 broadcast")
49+
}
50+
return nil
51+
}
52+
2553
// Round1P2PSend are values that are P2PSend to all other participants
2654
// after round1 completes
2755
type Round1P2PSend = map[uint32]*sharing.ShamirShare

pkg/sharing/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import "github.com/coinbase/kryptology/pkg/sharing"
3232
- [func NewShamir(threshold, limit uint32, curve *curves.Curve) (*Shamir, error)](<#func-newshamir>)
3333
- [func (s Shamir) Combine(shares ...*ShamirShare) (curves.Scalar, error)](<#func-shamir-combine>)
3434
- [func (s Shamir) CombinePoints(shares ...*ShamirShare) (curves.Point, error)](<#func-shamir-combinepoints>)
35-
- [func (s Shamir) LagrangeCoeffs(shares map[uint32]*ShamirShare) (map[uint32]curves.Scalar, error)](<#func-shamir-lagrangecoeffs>)
35+
- [func (s Shamir) LagrangeCoeffs(identities []uint32) (map[uint32]curves.Scalar, error)](<#func-shamir-lagrangecoeffs>)
3636
- [func (s Shamir) Split(secret curves.Scalar, reader io.Reader) ([]*ShamirShare, error)](<#func-shamir-split>)
3737
- [type ShamirShare](<#type-shamirshare>)
3838
- [func (ss ShamirShare) Bytes() []byte](<#func-shamirshare-bytes>)

pkg/sharing/feldman.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ func (f Feldman) LagrangeCoeffs(shares map[uint32]*ShamirShare) (map[uint32]curv
8585
limit: f.Limit,
8686
curve: f.Curve,
8787
}
88-
return shamir.LagrangeCoeffs(shares)
88+
identities := make([]uint32, 0)
89+
for _, xi := range shares {
90+
identities = append(identities, xi.Id)
91+
}
92+
return shamir.LagrangeCoeffs(identities)
8993
}
9094

9195
func (f Feldman) Combine(shares ...*ShamirShare) (curves.Scalar, error) {

pkg/sharing/pedersen.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ func (pd Pedersen) LagrangeCoeffs(shares map[uint32]*ShamirShare) (map[uint32]cu
125125
limit: pd.limit,
126126
curve: pd.curve,
127127
}
128-
return shamir.LagrangeCoeffs(shares)
128+
identities := make([]uint32, 0)
129+
for _, xi := range shares {
130+
identities = append(identities, xi.Id)
131+
}
132+
return shamir.LagrangeCoeffs(identities)
129133
}
130134

131135
func (pd Pedersen) Combine(shares ...*ShamirShare) (curves.Scalar, error) {

pkg/sharing/shamir.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ func (s Shamir) getPolyAndShares(secret curves.Scalar, reader io.Reader) ([]*Sha
8080
return shares, poly
8181
}
8282

83-
func (s Shamir) LagrangeCoeffs(shares map[uint32]*ShamirShare) (map[uint32]curves.Scalar, error) {
84-
xs := make(map[uint32]curves.Scalar, len(shares))
85-
for i, xi := range shares {
86-
xs[i] = s.curve.Scalar.New(int(xi.Id))
83+
func (s Shamir) LagrangeCoeffs(identities []uint32) (map[uint32]curves.Scalar, error) {
84+
xs := make(map[uint32]curves.Scalar, len(identities))
85+
for _, xi := range identities {
86+
xs[xi] = s.curve.Scalar.New(int(xi))
8787
}
8888

89-
result := make(map[uint32]curves.Scalar, len(shares))
89+
result := make(map[uint32]curves.Scalar, len(identities))
9090
for i, xi := range xs {
9191
num := s.curve.Scalar.One()
9292
den := s.curve.Scalar.One()

0 commit comments

Comments
 (0)