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

problem with p256Curve #10

Open
juan98mg opened this issue May 16, 2023 · 5 comments
Open

problem with p256Curve #10

juan98mg opened this issue May 16, 2023 · 5 comments

Comments

@juan98mg
Copy link

2023/05/15 19:15:59 gob: type elliptic.p256Curve has no exported fields

that appears when trying to create a wallet

@juan98mg
Copy link
Author

I supposed it could be the go version. can you specify which version you use to create it

@timokoz
Copy link

timokoz commented Jun 27, 2023

same issue here

@yuntian-he
Copy link

same issue

@yuntian-he
Copy link

yuntian-he commented Jul 1, 2023

What I have done for fix the problem.
Modify wallet.go

type Wallet struct {
	PrivateKeyD []byte
	PublicKey  []byte
}

func NewKeyPair() (*big.Int, []byte) {
	curve := elliptic.P256()

	private, err := ecdsa.GenerateKey(curve, rand.Reader)
	if err != nil {
		log.Panic(err)
	}

	pub := append(private.PublicKey.X.Bytes(), private.PublicKey.Y.Bytes()...)
	return private.D, pub
}

func MakeWallet() *Wallet {
	privateD, public := NewKeyPair()
	wallet := Wallet{privateD.Bytes(), public}

	return &wallet
}

func (w *Wallet) GetPrivateKey() *ecdsa.PrivateKey {
	d := new(big.Int).SetBytes(w.PrivateKeyD)
	curve := elliptic.P256()

	priv := &ecdsa.PrivateKey{
		PublicKey: ecdsa.PublicKey{
			Curve: curve,
			X:     nil,
			Y:     nil,
		},
		D: d,
	}

	return priv
}

But the private key is not encrypted

@timokoz
Copy link

timokoz commented Jul 3, 2023

Fix: Download go 1.13

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

No branches or pull requests

3 participants