Merge pull request #1678 from filecoin-project/asr/verifysig

The VerifySig syscall should verify sigs
This commit is contained in:
Whyrusleeping 2020-05-05 15:00:58 -07:00 committed by GitHub
commit 51142f45c3
3 changed files with 17 additions and 9 deletions

View File

@ -20,6 +20,7 @@ import (
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/store"
@ -37,8 +38,16 @@ func MinerAddress(genesisIndex uint64) address.Address {
return maddr
}
type fakedSigSyscalls struct {
runtime.Syscalls
}
func (fss *fakedSigSyscalls) VerifySignature(signature crypto.Signature, signer address.Address, plaintext []byte) error {
return nil
}
func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid, miners []genesis.Miner) (cid.Cid, error) {
vm, err := vm.NewVM(sroot, 0, &fakeRand{}, cs.Blockstore(), cs.VMSys())
vm, err := vm.NewVM(sroot, 0, &fakeRand{}, cs.Blockstore(), &fakedSigSyscalls{cs.VMSys()})
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err)
}

View File

@ -279,8 +279,6 @@ func (rt *Runtime) DeleteActor(addr address.Address) {
}
}
const GasVerifySignature = 50
func (rs *Runtime) Syscalls() vmr.Syscalls {
// TODO: Make sure this is wrapped in something that charges gas for each of the calls
return rs.sys

View File

@ -243,11 +243,12 @@ func (ss *syscallShim) VerifySeal(info abi.SealVerifyInfo) error {
}
func (ss *syscallShim) VerifySignature(sig crypto.Signature, addr address.Address, input []byte) error {
return nil
/* // TODO: in genesis setup, we are currently faking signatures
if err := ss.rt.vmctx.VerifySignature(&sig, addr, input); err != nil {
return false
// TODO: in genesis setup, we are currently faking signatures
kaddr, err := ResolveToKeyAddr(ss.cstate, ss.cst, addr)
if err != nil {
return err
}
return true
*/
return sigs.Verify(&sig, kaddr, input)
}