Skip to content
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

Support sr25519 curve #327

Closed
5 tasks
robdefeo opened this issue Oct 24, 2019 · 19 comments · Fixed by #360
Closed
5 tasks

Support sr25519 curve #327

robdefeo opened this issue Oct 24, 2019 · 19 comments · Fixed by #360

Comments

@robdefeo
Copy link
Member

robdefeo commented Oct 24, 2019

Is your feature request related to a problem? Please describe.
Substrate uses SR25519

Describe the solution you'd like
Implement sr25519 algorithm against the the PublicKey and PrivateKey interfaces

// PrivateKey definition usable in all mailchain crypto operations
type PrivateKey interface {
	// Bytes returns the byte representation of the private key
	Bytes() []byte
	// PublicKey from the PrivateKey
	PublicKey() PublicKey
        Sign(message []byte) (signature []byte, err error)
}

// PublicKey definition usable in all mailchain crypto operations
type PublicKey interface {
	// Bytes returns the byte representation of the public key
	Bytes() []byte
        Verify(data []byte) error
}

Additional items

  • Test package sr25519test with sofia
  Secret seed: 0x5c6d7adf75bda1180c225d25f3aa8dc174bbfb3cddee11ae9a85982f6faf791a
  Public key (hex): 0x169a11721851f5dff3541dd5c4b0b478ac1cd092c9d5976e83daa0d03f26620c
  Address (SS58): 5CaLgJUDdDRxw6KQXJY2f5hFkMEEGHvtUPQYDWdSbku42Dv2
  • Test package sr25519test with charlotte
  Secret seed: 0x23b063a581fd8e5e847c4e2b9c494247298791530f5293be369e8bf23a45d2bd
  Public key (hex): 0x84623e7252e41138af6904e1b02304c941625f39e5762589125dc1a2f2cf2e30
  Address (SS58): 5F4HMyes8GNWzpSDjTPSh61Aw6RTaWmZKwKvszocwqbsdn4h
  • Test under the nacl package to test encryption with sofia and charlotte keys
  • PrivateKeyFromBytes(privKey []byte) takes seed or full private key bytes
  • PublicKeyFromBytes
  • [ ]

Describe alternatives you've considered
Using CGO to and calling https://github.com/Warchant/sr25519-crust C bindings exist against https://github.com/w3f/schnorrkel

Additional context

  • Useful information about the keys
const (
	chainCodeSize  = 32
	keyPairSize    = 96
	publicKeySize     = 32
	privateKeySize     = 64
	seedSize       = 32
	signatureSize  = 64
	vrfOutputSize = 32
	vrfProofSize  = 64
)
@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 300.0 DAI (300.0 USD @ $1.0/DAI) attached to it.

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Workers have applied to start work.

These users each claimed they can complete the work by 3 weeks, 6 days from now.
Please review their action plans below:

1) developerfred has applied to start work (Funders only: approve worker | reject worker).

I will go create Elliptic Curve algorithm with pokadot docs and ristretto docs. This math struct
nG = Hn*
P dot P dot

base
[1]Decaf: Eliminating cofactors though point compression - Mike Hamburg

Learn more on the Gitcoin Issue Details page.

@gitcoinbot
Copy link

@developerfred Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

1 similar comment
@gitcoinbot
Copy link

@developerfred Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

developerfred added a commit to developerfred/mailchain that referenced this issue Nov 8, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 10, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 10, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 10, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 11, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
- add news rules on .gitignore
- fixed problens on ristretto package

	modified:   .gitignore

	modified:   crypto/sr25519/keys_test.go
	modified:   crypto/sr25519/public.go
	modified:   crypto/sr25519/sr25519test/keys.go

	new file:   go.mod

	modified:   crypto/cipher/nacl/nacl_test.go
	new file:   go.mod

	new file:   go.mod
	new file:   go.sum

	new file:   go.mod

	modified:   .gitignore
	modified:   crypto/cipher/nacl/nacl_test.go
	modified:   crypto/sr25519/keys_test.go
	modified:   crypto/sr25519/private.go
	modified:   crypto/sr25519/public.go
	modified:   crypto/sr25519/sr25519test/keys.go
	new file:   go.mod
	new file:   go.sum
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
 Changes to be committed:
	modified:   private.go
	modified:   public.go
	modified:   sr25519test/keys.go
	modified:   keys_test.go
	modified:   ../../go.mod
developerfred added a commit to developerfred/mailchain that referenced this issue Nov 20, 2019
@gitcoinbot
Copy link

@developerfred Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

3 similar comments
@gitcoinbot
Copy link

@developerfred Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot
Copy link

@developerfred Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot
Copy link

@developerfred Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Workers have applied to start work.

These users each claimed they can complete the work by 1 day, 9 hours from now.
Please review their action plans below:

1) developerfred has applied to start work (Funders only: approve worker | reject worker).

I'm trying to submit my pull request and I'm not getting here is the link
#360

Learn more on the Gitcoin Issue Details page.

@gitcoinbot
Copy link

gitcoinbot commented Nov 30, 2019

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 3 weeks, 1 day ago.
Please review their action plans below:

1) developerfred has been approved to start work.

I'm trying to submit my pull request and I'm not getting here is the link
#360
2) developerfred has been approved to start work.

I'm trying to submit my pull request and I'm not getting here is the link
#360

Learn more on the Gitcoin Issue Details page.

@developerfred
Copy link
Contributor

developerfred commented Nov 30, 2019

Is your feature request related to a problem? Please describe.
Substrate uses SR25519

Describe the solution you'd like
Implement sr25519 algorithm against the the PublicKey and PrivateKey interfaces

// PrivateKey definition usable in all mailchain crypto operations
type PrivateKey interface {
	// Bytes returns the byte representation of the private key
	Bytes() []byte
	// PublicKey from the PrivateKey
	PublicKey() PublicKey
        Sign(message []byte) (signature []byte, err error)
}

// PublicKey definition usable in all mailchain crypto operations
type PublicKey interface {
	// Bytes returns the byte representation of the public key
	Bytes() []byte
        Verify(data []byte) error
}

Additional items

  • Test package sr25519test with sofia
  Secret seed: 0x5c6d7adf75bda1180c225d25f3aa8dc174bbfb3cddee11ae9a85982f6faf791a
  Public key (hex): 0x169a11721851f5dff3541dd5c4b0b478ac1cd092c9d5976e83daa0d03f26620c
  Address (SS58): 5CaLgJUDdDRxw6KQXJY2f5hFkMEEGHvtUPQYDWdSbku42Dv2
  • Test package sr25519test with charlotte
  Secret seed: 0x23b063a581fd8e5e847c4e2b9c494247298791530f5293be369e8bf23a45d2bd
  Public key (hex): 0x84623e7252e41138af6904e1b02304c941625f39e5762589125dc1a2f2cf2e30
  Address (SS58): 5F4HMyes8GNWzpSDjTPSh61Aw6RTaWmZKwKvszocwqbsdn4h
  • [x ] Test under the nacl package to test encryption with sofia and charlotte keys
  • PrivateKeyFromBytes(privKey []byte) takes seed or full private key bytes
  • PublicKeyFromBytes
  • [ ]

Describe alternatives you've considered
Using CGO to and calling https://github.com/Warchant/sr25519-crust C bindings exist against https://github.com/w3f/schnorrkel

Additional context

  • Useful information about the keys
const (
	chainCodeSize  = 32
	keyPairSize    = 96
	publicKeySize     = 32
	privateKeySize     = 64
	seedSize       = 32
	signatureSize  = 64
	vrfOutputSize = 32
	vrfProofSize  = 64
)
  • test sing
  • test verify

@gitcoinbot
Copy link

@developerfred Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

1 similar comment
@gitcoinbot
Copy link

@developerfred Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 300.0 SAI (300.0 USD @ $1.0/SAI) has been submitted by:

  1. @developerfred

@Web3Foundation please take a look at the submitted work:


@Web3Foundation
Copy link

@robdefeo what's the latest on the PR with this issue? Feel free to ping me on @chris:web3.foundation on riot if we need to discuss further than here.

@robdefeo
Copy link
Member Author

@Web3Foundation I have been working with @developerfred and we are really close to resolving this PR. It had some complications but I believe they have now been overcome. Thanks

@developerfred developerfred mentioned this issue Jan 24, 2020
2 tasks
robdefeo added a commit that referenced this issue Jan 24, 2020
* [WIP] #327 - start struct folders

* add new key sr25519

* [WIP] - private.go sr25519

* [WIP - #327] public key add

* [WIP] #327 add test rules

* add files on go.mod and fixed ristreto to ristretto

* [WIP] - create sr25519 module

* [WIP] public.go done[x] need test file

* [WIP]#327 - Public and Keys test files

* [WIP]test keys file

* #327 add function PrivateKeyfromBytes

* add news rules on go.mod

* Review this go.mod and go.sum

* add strobe/debug on .gitignore

* fixed tests

* fixed package ristretto 255

* fixed ristretto on private key

* fixed ristretto module

*  #327 merlin fixed

* change merlin version

*  update go mod

* fixed go get -v ./..

* fixed versions on go.md

* fixed version to 0.1.3

	modified:   go.mod
	modified:   ../../go.mod
	go.sum

* fixed sr25519 package

	modified:   crypto/sr25519/go.mod

* 	modified:   ../../.golangci.yml
	modified:   ../../cmd/mailchain/commands/account.go
	modified:   ../multikey/private_test.go
	deleted:    go.mod

	modified:   .golangci.yml
	modified:   cmd/mailchain/commands/account.go
	modified:   crypto/multikey/private_test.go
	deleted:    crypto/sr25519/go.mod
	modified:   crypto/sr25519/public.go

* #327 add sr25519 on nacl files

* - #327 Create go mod for sr25519

- add news rules on .gitignore
- fixed problens on ristretto package

	modified:   .gitignore

	modified:   crypto/sr25519/keys_test.go
	modified:   crypto/sr25519/public.go
	modified:   crypto/sr25519/sr25519test/keys.go

	new file:   go.mod

	modified:   crypto/cipher/nacl/nacl_test.go
	new file:   go.mod

	new file:   go.mod
	new file:   go.sum

	new file:   go.mod

	modified:   .gitignore
	modified:   crypto/cipher/nacl/nacl_test.go
	modified:   crypto/sr25519/keys_test.go
	modified:   crypto/sr25519/private.go
	modified:   crypto/sr25519/public.go
	modified:   crypto/sr25519/sr25519test/keys.go
	new file:   go.mod
	new file:   go.sum

*  #327 - update sr25519

 Changes to be committed:
	modified:   private.go
	modified:   public.go
	modified:   sr25519test/keys.go
	modified:   keys_test.go
	modified:   ../../go.mod

*  #327 - update sr25519

 Changes to be committed:
	modified:   private.go
	modified:   public.go
	modified:   sr25519test/keys.go
	modified:   keys_test.go
	modified:   ../../go.mod

* sr25519: cipher ncl #327 [x]

* add new function for converte string in byte array

* sr25519: [x] KeyPair
- [x] Charlotte and Sofie Tests
- [x] PrivateKeyToBytes

* add keys of thes sr25519

* [WIP] #327 - start struct folders

* add new key sr25519

* [WIP] - private.go sr25519

* [WIP - #327] public key add

* [WIP] #327 add test rules

* add files on go.mod and fixed ristreto to ristretto

* [WIP] - create sr25519 module

* [WIP] public.go done[x] need test file

* [WIP]#327 - Public and Keys test files

* [WIP]test keys file

* #327 add function PrivateKeyfromBytes

* add news rules on go.mod

* Review this go.mod and go.sum

* add strobe/debug on .gitignore

* fixed tests

* fixed package ristretto 255

* fixed ristretto on private key

* fixed ristretto module

*  #327 merlin fixed

* change merlin version

*  update go mod

* fixed go get -v ./..

* fixed versions on go.md

* fixed version to 0.1.3

	modified:   go.mod
	modified:   ../../go.mod
	go.sum

* fixed sr25519 package

	modified:   crypto/sr25519/go.mod

* #327 add sr25519 on nacl files

* sr25519: cipher ncl #327 [x]

* add new function for converte string in byte array

* Review this go.mod and go.sum

* 	modified:   ../../.golangci.yml
	modified:   ../../cmd/mailchain/commands/account.go
	modified:   ../multikey/private_test.go
	deleted:    go.mod

	modified:   .golangci.yml
	modified:   cmd/mailchain/commands/account.go
	modified:   crypto/multikey/private_test.go
	deleted:    crypto/sr25519/go.mod
	modified:   crypto/sr25519/public.go

* - #327 Create go mod for sr25519

- add news rules on .gitignore
- fixed problens on ristretto package

	modified:   .gitignore

	modified:   crypto/sr25519/keys_test.go
	modified:   crypto/sr25519/public.go
	modified:   crypto/sr25519/sr25519test/keys.go

	new file:   go.mod

	modified:   crypto/cipher/nacl/nacl_test.go
	new file:   go.mod

	new file:   go.mod
	new file:   go.sum

	new file:   go.mod

	modified:   .gitignore
	modified:   crypto/cipher/nacl/nacl_test.go
	modified:   crypto/sr25519/keys_test.go
	modified:   crypto/sr25519/private.go
	modified:   crypto/sr25519/public.go
	modified:   crypto/sr25519/sr25519test/keys.go
	new file:   go.mod
	new file:   go.sum

*  #327 - update sr25519

 Changes to be committed:
	modified:   private.go
	modified:   public.go
	modified:   sr25519test/keys.go
	modified:   keys_test.go
	modified:   ../../go.mod

* sr25519: cipher ncl #327 [x]

* add keys of thes sr25519

* Delete go.sum

* [WIP] sr25519

* suggest changes

* update keys on sr25519

* - [x] TestPrivateKey
- [x] TestPublicKey

* sr25519

* sr25519

* add sr25519 on multikey

* gofmt on sr25519

*  sr25519test/keys.go

* change msg err

* add charlotte sr25519 on multikey

*  add encodingtest.MustDecodeHex

* add encodingtest.MustDecodeHex on ed25519

* add encodingtest.MustDecodeHex on ed25519

	new file:   crypto/sr25519/end_end_test.go

* [WIP] TestPrivateKey_PublicKey same key

*  TestPrivateKey_public fail

*  PublicKey()

*  Publickey is working

*  sr25519: PrivateKey to PulicKey() [x]

* remove keypair.go

* update: address_test add #sr25519

* remove encoding and decoding

*  *[x] Add test case for sr25519 in TestEncrypter_Encrypt crypto/cipher/nacl/encrypt_test.go

* [x] add end_end_test
[x] sign/verify tests
[x] encrypt decrypt tests with nacl

* [ ] Nacl Error

* feat: create key exchange for sr25519 package #505

* native sr25519

* create key exchange for sr25519

* fix linting

* fix linting

* fix linting

* more tests

Co-authored-by: Rob De Feo <robertodefeo@hotmail.com>
@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 300.0 SAI (300.0 USD @ $1.0/SAI) attached to this issue has been approved & issued to @developerfred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants