Skip to content

problem with p256Curve #10

@juan98mg

Description

@juan98mg

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

that appears when trying to create a wallet

Activity

juan98mg

juan98mg commented on May 16, 2023

@juan98mg
Author

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

timokoz

timokoz commented on Jun 27, 2023

@timokoz

same issue here

yuntian-he

yuntian-he commented on Jul 1, 2023

@yuntian-he

same issue

yuntian-he

yuntian-he commented on Jul 1, 2023

@yuntian-he

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

timokoz commented on Jul 3, 2023

@timokoz

Fix: Download go 1.13

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      problem with p256Curve · Issue #10 · tensor-programming/golang-blockchain