Skip to content
Closed
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
17 changes: 8 additions & 9 deletions cgo/extern.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ import (
"github.com/filecoin-project/go-address"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"
)

//export cgo_extern_get_chain_randomness
func cgo_extern_get_chain_randomness(
handle C.uint64_t, pers C.int64_t, round C.int64_t,
entropy C.buf_t, entropyLen C.int32_t,
handle C.uint64_t,
round C.int64_t,
output C.buf_t,
) (res C.int32_t) {
defer func() {
Expand All @@ -33,11 +32,11 @@ func cgo_extern_get_chain_randomness(
return ErrInvalidHandle
}

rand, err := externs.GetChainRandomness(ctx, crypto.DomainSeparationTag(pers), abi.ChainEpoch(round), C.GoBytes(unsafe.Pointer(entropy), entropyLen))
rand, err := externs.GetChainRandomness(ctx, abi.ChainEpoch(round))

switch err {
case nil:
copy(out[:], rand)
copy(out[:], rand[:])
return 0
default:
return ErrIO
Expand All @@ -46,8 +45,8 @@ func cgo_extern_get_chain_randomness(

//export cgo_extern_get_beacon_randomness
func cgo_extern_get_beacon_randomness(
handle C.uint64_t, pers C.int64_t, round C.int64_t,
entropy C.buf_t, entropyLen C.int32_t,
handle C.uint64_t,
round C.int64_t,
output C.buf_t,
) (res C.int32_t) {
defer func() {
Expand All @@ -63,11 +62,11 @@ func cgo_extern_get_beacon_randomness(
return ErrInvalidHandle
}

rand, err := externs.GetBeaconRandomness(ctx, crypto.DomainSeparationTag(pers), abi.ChainEpoch(round), C.GoBytes(unsafe.Pointer(entropy), entropyLen))
rand, err := externs.GetBeaconRandomness(ctx, abi.ChainEpoch(round))

switch err {
case nil:
copy(out[:], rand)
copy(out[:], rand[:])
return 0
default:
return ErrIO
Expand Down
5 changes: 2 additions & 3 deletions cgo/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/ipfs/go-cid"
blockstore "github.com/ipfs/go-ipfs-blockstore"
)
Expand All @@ -29,8 +28,8 @@ const (
)

type Externs interface {
GetChainRandomness(ctx context.Context, personalization crypto.DomainSeparationTag, epoch abi.ChainEpoch, entropy []byte) ([]byte, error)
GetBeaconRandomness(ctx context.Context, personalization crypto.DomainSeparationTag, epoch abi.ChainEpoch, entropy []byte) ([]byte, error)
GetChainRandomness(ctx context.Context, epoch abi.ChainEpoch) ([32]byte, error)
GetBeaconRandomness(ctx context.Context, epoch abi.ChainEpoch) ([32]byte, error)
VerifyConsensusFault(ctx context.Context, h1, h2, extra []byte) (*ConsensusFault, int64)
TipsetCid(ctx context.Context, epoch abi.ChainEpoch) (cid.Cid, error)

Expand Down
Loading