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

Upgrades proof-of-possession to use Ethereum address #556

Merged
merged 6 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ geth-defaults: &geth-defaults

rust-defaults: &rust-defaults
docker:
- image: circleci/rust:1.36.0
- image: circleci/rust:1.37.0

end-to-end-defaults: &end-to-end-defaults
docker:
Expand Down Expand Up @@ -46,8 +46,8 @@ jobs:
name: Setup Rust language
command: |
set -euo pipefail
rustup install 1.36.0
rustup default 1.36.0
rustup install 1.37.0
rustup default 1.37.0
- run:
name: Compile bls-zexe
command: |
Expand All @@ -69,7 +69,7 @@ jobs:
command: |
set -euo pipefail
export CELO_MONOREPO_DIR="$PWD"
git clone --depth 1 https://github.com/celo-org/celo-monorepo.git ${CELO_MONOREPO_DIR} -b master
git clone --depth 1 https://github.com/celo-org/celo-monorepo.git ${CELO_MONOREPO_DIR} -b kobigurk/pop_eth_address
yarn install || yarn install
# separate build to avoid ENOMEM in CI :(
yarn build --scope @celo/utils
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FROM ubuntu:16.04 as rustbuilder
RUN apt update && apt install -y curl musl-tools
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH=$PATH:~/.cargo/bin
RUN $HOME/.cargo/bin/rustup install 1.36.0 && $HOME/.cargo/bin/rustup default 1.36.0 && $HOME/.cargo/bin/rustup target add x86_64-unknown-linux-musl
RUN $HOME/.cargo/bin/rustup install 1.37.0 && $HOME/.cargo/bin/rustup default 1.37.0 && $HOME/.cargo/bin/rustup target add x86_64-unknown-linux-musl
ADD ./vendor /go-ethereum/vendor
RUN cd /go-ethereum/vendor/github.com/celo-org/bls-zexe/bls && $HOME/.cargo/bin/cargo build --target x86_64-unknown-linux-musl --release

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alltools
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:16.04 as rustbuilder
RUN apt update && apt install -y curl musl-tools
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN $HOME/.cargo/bin/rustup install 1.36.0 && $HOME/.cargo/bin/rustup default 1.36.0 && $HOME/.cargo/bin/rustup target add x86_64-unknown-linux-musl
RUN $HOME/.cargo/bin/rustup install 1.37.0 && $HOME/.cargo/bin/rustup default 1.37.0 && $HOME/.cargo/bin/rustup target add x86_64-unknown-linux-musl
ADD ./vendor /go-ethereum/vendor
RUN cd /go-ethereum/vendor/github.com/celo-org/bls-zexe/bls && $HOME/.cargo/bin/cargo build --target x86_64-unknown-linux-musl --release

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.android
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ ENV GOPATH=$HOME/go

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH=$PATH:$HOME/.cargo/bin
RUN rustup install 1.36.0
RUN rustup default 1.36.0
RUN rustup install 1.37.0
RUN rustup default 1.37.0
RUN rustup target add aarch64-linux-android
RUN rustup target add armv7-linux-androideabi
RUN rustup target add i686-linux-android
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# celohq/android-client

FROM circleci/rust:1.36.0-buster
FROM circleci/rust:1.37.0-buster

USER root

Expand Down
2 changes: 1 addition & 1 deletion accounts/keystore/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func (ks *KeyStore) GenerateProofOfPossession(a accounts.Account) ([]byte, error
}
defer privateKey.Destroy()

signature, err := privateKey.SignPoP()
signature, err := privateKey.SignPoP(a.Address.Bytes())
if err != nil {
return nil, err
}
Expand Down
9 changes: 5 additions & 4 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,25 +601,26 @@ func (c *proofOfPossession) Run(input []byte, caller common.Address, evm *EVM, g
// publicKey: 48 bytes, representing the public key (defined as a const in bls package)
// signature: 96 bytes, representing the signature (defined as a const in bls package)
// the total length of input required is the sum of these constants
if len(input) < blscrypto.PUBLICKEYBYTES+blscrypto.SIGNATUREBYTES {
if len(input) != common.AddressLength+blscrypto.PUBLICKEYBYTES+blscrypto.SIGNATUREBYTES {
return nil, gas, ErrInputLength
}
addressBytes := input[:common.AddressLength]

publicKeyBytes := input[:blscrypto.PUBLICKEYBYTES]
publicKeyBytes := input[common.AddressLength : common.AddressLength+blscrypto.PUBLICKEYBYTES]
publicKey, err := bls.DeserializePublicKey(publicKeyBytes)
if err != nil {
return nil, gas, err
}
defer publicKey.Destroy()

signatureBytes := input[blscrypto.PUBLICKEYBYTES : blscrypto.PUBLICKEYBYTES+blscrypto.SIGNATUREBYTES]
signatureBytes := input[common.AddressLength+blscrypto.PUBLICKEYBYTES : common.AddressLength+blscrypto.PUBLICKEYBYTES+blscrypto.SIGNATUREBYTES]
signature, err := bls.DeserializeSignature(signatureBytes)
if err != nil {
return nil, gas, err
}
defer signature.Destroy()

err = publicKey.VerifyPoP(signature)
err = publicKey.VerifyPoP(addressBytes, signature)
if err != nil {
return nil, gas, err
}
Expand Down
4 changes: 3 additions & 1 deletion crypto/bls/bls_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package blscrypto

import (
"encoding/hex"
"testing"

"github.com/celo-org/bls-zexe/go"
Expand All @@ -16,7 +17,8 @@ func TestECDSAToBLS(t *testing.T) {
publicKeyBLSBytes, _ := publicKeyBLS.Serialize()
t.Logf("public key: %x", publicKeyBLSBytes)

pop, _ := privateKeyBLS.SignPoP()
address, _ := hex.DecodeString("4f837096cd8578c1f14c9644692c444bbb614262")
pop, _ := privateKeyBLS.SignPoP(address)
popBytes, _ := pop.Serialize()
t.Logf("pop: %x", popBytes)
}
2 changes: 1 addition & 1 deletion vendor/github.com/celo-org/bls-zexe/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 25 additions & 49 deletions vendor/github.com/celo-org/bls-zexe/bls/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions vendor/github.com/celo-org/bls-zexe/bls/algebra/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading