-
Notifications
You must be signed in to change notification settings - Fork 179
Add marshalling for deal #610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thehoul
merged 12 commits into
remove-protobuf-dependencies
from
add-marshalling-for-deal
Feb 20, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
969631d
add marshaling for share.PriShare
thehoul b4fcc16
add marshaling for Pedersen VSS Deal
thehoul 3b32aff
add marshaling for Rabin VSS Deal
thehoul eee2308
move Rabin VSS Deal marhsalling to vss.go
thehoul 4419808
move Pedersen VSS Deal marhsalling to vss.go
thehoul 5d10ce3
use Marshal method in Rabin DKG instead of protobuf
thehoul b049d3f
fix Pedersen tests
thehoul 23d5f79
unexport adapter structs for VSS and PriShare
thehoul f9d08e4
swap TypeOf for TypeFor
thehoul cbbfc93
add check before casting int64 to uint32
thehoul 04b42ed
add doc in v3marshaling.go
thehoul 25caede
add doc in vss.go for both Rabin and Pedersen
thehoul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package internal | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "math" | ||
| "reflect" | ||
|
|
||
| "go.dedis.ch/kyber/v4" | ||
| "go.dedis.ch/kyber/v4/internal/protobuf" | ||
| "go.dedis.ch/kyber/v4/share" | ||
| ) | ||
|
|
||
| // Suite defines the capabilities required by the v3marshalling package. | ||
| type Suite interface { | ||
| // Group is needed for Group.Scalar | ||
| kyber.Group | ||
| } | ||
|
|
||
| // compatiblePriShare is a struct for PriShare used when marshaling to | ||
| // ensure compatibility with V3 | ||
| type compatiblePriShare struct { | ||
| I int64 | ||
| V kyber.Scalar | ||
| } | ||
|
|
||
| // MarshalPriShare marshals a share.PriShare into bytes or returns an error | ||
| // if the encoding did not work. Encoding is compatible with Kyber V3 | ||
| func MarshalPriShare(priShare *share.PriShare) ([]byte, error) { | ||
|
thehoul marked this conversation as resolved.
|
||
| toEncode := &compatiblePriShare{ | ||
| I: int64(priShare.I), | ||
| V: priShare.V, | ||
| } | ||
| return protobuf.Encode(toEncode) | ||
| } | ||
|
|
||
| // UnmarshalPriShare unmarshals a share.PriShare from bytes or returns an error | ||
| // if the decoding did not work. Decoding is compatible with Kyber V3 | ||
| func UnmarshalPriShare(data []byte, suite Suite) (*share.PriShare, error) { | ||
|
thehoul marked this conversation as resolved.
|
||
| compatiblePriShare := &compatiblePriShare{} | ||
| constructors := make(protobuf.Constructors) | ||
| constructors[reflect.TypeFor[kyber.Scalar]()] = func() interface{} { return suite.Scalar() } | ||
| err := protobuf.DecodeWithConstructors(data, compatiblePriShare, constructors) | ||
|
|
||
| // Check for overflow on I | ||
| if compatiblePriShare.I < 0 || compatiblePriShare.I > math.MaxUint32 { | ||
| return nil, fmt.Errorf("cannot cast I as int64 to uint32 due to overflow") | ||
| } | ||
|
|
||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| priShare := &share.PriShare{ | ||
| I: uint32(compatiblePriShare.I), | ||
|
thehoul marked this conversation as resolved.
|
||
| V: compatiblePriShare.V, | ||
| } | ||
| return priShare, nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.