Skip to content

Commit 6240a50

Browse files
committed
wip scopes implementation
1 parent 30a3cf0 commit 6240a50

17 files changed

+967
-607
lines changed

authorizer.go

Lines changed: 180 additions & 173 deletions
Large diffs are not rendered by default.

authorizer_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ func TestVerifierSerializeLoad(t *testing.T) {
152152
v1.AddRule(rule1)
153153
v1.AddCheck(check1)
154154
v1.AddPolicy(policy)
155-
s, err := v1.SerializePolicies()
156-
require.NoError(t, err)
155+
// s, err := v1.SerializePolicies()
156+
// require.NoError(t, err)
157157

158158
v2, err := b.Authorizer(publicRoot)
159159
require.NoError(t, err)
160160

161-
require.NoError(t, v2.LoadPolicies(s))
161+
// require.NoError(t, v2.LoadPolicies(s))
162162

163163
require.Equal(t, v1.(*authorizer).world.Facts(), v2.(*authorizer).world.Facts())
164164
require.Equal(t, v1.(*authorizer).world.Rules(), v2.(*authorizer).world.Rules())

biscuit.go

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -504,30 +504,30 @@ func (b *Biscuit) Serialize() ([]byte, error) {
504504

505505
var ErrFactNotFound = errors.New("biscuit: fact not found")
506506

507-
// GetBlockID returns the first block index containing a fact
508-
// starting from the authority block and then each block in the order they were added.
509-
// ErrFactNotFound is returned when no block contains the fact.
510-
func (b *Biscuit) GetBlockID(fact Fact) (int, error) {
511-
// don't store symbols from searched fact in the verifier table
512-
symbols := b.symbols.Clone()
513-
datalogFact := fact.Predicate.convert(symbols)
514-
515-
for _, f := range *b.authority.facts {
516-
if f.Equal(datalogFact) {
517-
return 0, nil
518-
}
519-
}
520-
521-
for i, b := range b.blocks {
522-
for _, f := range *b.facts {
523-
if f.Equal(datalogFact) {
524-
return i + 1, nil
525-
}
526-
}
527-
}
528-
529-
return 0, ErrFactNotFound
530-
}
507+
// // GetBlockID returns the first block index containing a fact
508+
// // starting from the authority block and then each block in the order they were added.
509+
// // ErrFactNotFound is returned when no block contains the fact.
510+
// func (b *Biscuit) GetBlockID(fact Fact) (int, error) {
511+
// // don't store symbols from searched fact in the verifier table
512+
// symbols := b.symbols.Clone()
513+
// datalogFact := fact.Predicate.convert(symbols)
514+
515+
// for _, f := range *b.authority.facts {
516+
// if f.Equal(datalogFact) {
517+
// return 0, nil
518+
// }
519+
// }
520+
521+
// for i, b := range b.blocks {
522+
// for _, f := range *b.facts {
523+
// if f.Equal(datalogFact) {
524+
// return i + 1, nil
525+
// }
526+
// }
527+
// }
528+
529+
// return 0, ErrFactNotFound
530+
// }
531531

532532
/*
533533
// SHA256Sum returns a hash of `count` biscuit blocks + the authority block
@@ -609,33 +609,35 @@ func (b *Biscuit) checkRootKey(root ed25519.PublicKey) error {
609609
return nil
610610
}*/
611611

612-
func (b *Biscuit) generateWorld(symbols *datalog.SymbolTable) (*datalog.World, error) {
613-
world := datalog.NewWorld()
612+
// func (b *Biscuit) generateWorld(symbols *datalog.SymbolTable) (*datalog.World, error) {
613+
// world := datalog.NewWorld()
614614

615-
for _, fact := range *b.authority.facts {
616-
world.AddFact(fact)
617-
}
615+
// authorityOrigin := datalog.AuthorityOrigin()
616+
// for _, fact := range b.authority.facts {
617+
// world.AddFact(authorityOrigin, fact)
618+
// }
618619

619-
for _, rule := range b.authority.rules {
620-
world.AddRule(rule)
621-
}
620+
// for _, rule := range b.authority.rules {
621+
// world.AddRule(0, rule)
622+
// }
622623

623-
for _, block := range b.blocks {
624-
for _, fact := range *block.facts {
625-
world.AddFact(fact)
626-
}
624+
// for index, block := range b.blocks {
625+
// blockOrigin := datalog.MakeOrigin([]uint64{uint64(index + 1)})
626+
// for _, fact := range block.facts {
627+
// world.AddFact(blockOrigin, fact)
628+
// }
627629

628-
for _, rule := range block.rules {
629-
world.AddRule(rule)
630-
}
631-
}
630+
// for _, rule := range block.rules {
631+
// world.AddRule(datalog.SingleOrigin(index+1), rule)
632+
// }
633+
// }
632634

633-
if err := world.Run(symbols); err != nil {
634-
return nil, err
635-
}
635+
// if err := world.Run(symbols); err != nil {
636+
// return nil, err
637+
// }
636638

637-
return world, nil
638-
}
639+
// return world, nil
640+
// }
639641

640642
func (b *Biscuit) RevocationIds() [][]byte {
641643
result := make([][]byte, 0, len(b.blocks)+1)

0 commit comments

Comments
 (0)