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

Ledger acess rights control #34

Merged
merged 9 commits into from
Apr 8, 2020
Merged

Ledger acess rights control #34

merged 9 commits into from
Apr 8, 2020

Conversation

Gilthoniel
Copy link
Contributor

This adds the ARC principle to Byzcoin with some missing implementation.

@Gilthoniel Gilthoniel self-assigned this Apr 7, 2020
@Gilthoniel Gilthoniel requested a review from nkcr April 7, 2020 07:11
@Gilthoniel Gilthoniel added the R4M 🚀 The PR is ready to be reviewed and merged label Apr 7, 2020

err := bls.Verify(suite, pk.point, msg, signature.data)
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xerrors.errorf(...)

crypto/bls/mod.go Show resolved Hide resolved
return "bls:malformed point"
}

return string(buffer)[:4+16]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would comment why those numbers

func (pk publicKey) String() string {
buffer, err := pk.MarshalText()
if err != nil {
return "bls:malformed point"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that could help if there were no space, especially in cases where there is some text parsing. Maybe return "bls:malformed_point" ?


// Register binds a protobuf message type to a public key factory. If a key
// already exists, it will override it.
func (f PublicKeyFactory) Register(msg proto.Message, factory crypto.PublicKeyFactory) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not taking directly a reflect.Type instead of a proto.Message ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems more natural and user-friendly because you want to register a type of message to be handled by a factory. Also we can switch to something else later if reflect is problematic.

// Spawn is called to create a new instance.
Spawn(ctx SpawnContext) (proto.Message, error)
// Spawn is called to create a new instance. It returns the initial value of
// the new instance and its access control ID.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// the new instance and its access control ID.
// the new instance and its access rule control (arc) ID.

if err != nil {
return nil, xerrors.Errorf("couldn't read the instance: %v", err)
}

contractID := inst.GetContractID()
contractID := inst.(ContractInstance).GetContractID()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no check?

func (c Consumer) hasAccess(ctx consumer.Context, key []byte, rule string) error {
instance, err := ctx.Read(key)
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xerrors.Errorf(...)
same bellow

hash []byte
nonce uint64
action action
identity crypto.PublicKey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only one identity and one signature?

Copy link
Contributor Author

@Gilthoniel Gilthoniel Apr 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes because it doesn't make sense to have multiple signatures for one transaction. We can later implement a deferred transaction smart contract to have multiple signatures but when creating a transaction, you usually have one signing key.

switch tx := txProto.(type) {
case *SpawnTransactionProto:
arg, err := f.encoder.UnmarshalDynamicAny(tx.GetArgument())
if spawn := txProto.GetSpawn(); spawn != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

@Gilthoniel Gilthoniel requested a review from nkcr April 8, 2020 08:26
Copy link
Contributor

@nkcr nkcr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being annoying but it's your fault: If the code wasn't that well written I wouldn't care keeping it up to excellence :p
(Broken window theory: even if "as is" it's not that grave I want to avoid any bit of code that could be a sign for one "stranger" to write lower quality code)

// of the signature if the message is a known signature message, otherwise it
// returns an error.
func (f SignatureFactory) FromProto(in proto.Message) (crypto.Signature, error) {
if inAny, ok := in.(*any.Any); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✌️

// FromProto implements arc.AccessControlFactory. It returns the access control
// associated with the message.
func (f *AccessControlFactory) FromProto(pb proto.Message) (arc.AccessControl, error) {
if pbAny, ok := pb.(*any.Any); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✌️

@nkcr nkcr merged commit 49d0969 into master Apr 8, 2020
@nkcr nkcr deleted the ledger_permissions branch April 8, 2020 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R4M 🚀 The PR is ready to be reviewed and merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants