Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4f88e97
Add minimum annotations to verify private/topology
henriman Feb 1, 2025
c8b7b5c
Add appropriate postconditions to private/topology
henriman Feb 1, 2025
2380d49
Merge branch 'sif-private-topology-underlay' into sif-private-topology
henriman Feb 1, 2025
9863f30
Add assumption due to Gobra issue #835
henriman Feb 1, 2025
12c655e
Merge branch 'sif-private-topology-underlay' into sif-private-topology
henriman Feb 2, 2025
9e03a1a
Merge branch 'sif-private-topology-underlay' into sif-private-topology
henriman Feb 11, 2025
75df8c6
Merge branch 'sif-private-topology-underlay' into sif-private-topology
henriman Feb 13, 2025
8283193
Introduce functions to express assumptions
henriman Feb 14, 2025
3e12921
Merge branch 'sif-private-topology-underlay' into sif-private-topology
henriman Feb 27, 2025
ea50e39
Merge branch 'master' of https://github.com/viperproject/VerifiedSCIO…
henriman Mar 2, 2025
44a0b6d
Merge branch 'sif-private-topology' of https://github.com/henriman/Ve…
henriman Mar 13, 2025
01950a7
Fix typo
henriman Mar 13, 2025
5772210
Merge branch 'sif-private-topology-underlay' into sif-private-topology
henriman Apr 14, 2025
1e0500b
Clean up
henriman Apr 14, 2025
29e7444
Rename `AssumeLowSliceToLowString` to `LowSliceImpliesLowString`
henriman Apr 14, 2025
3781fa0
Merge branch 'sif-private-topology-underlay' into sif-private-topology
henriman Jun 26, 2025
b89413f
Merge branch 'sif-private-topology-underlay' into sif-private-topology
henriman Jul 2, 2025
8f3c41c
Remove workaround for Gobra issue #835/#890
henriman Jul 2, 2025
064c6eb
Merge branch 'sif-private-topology-underlay' into sif-private-topology
henriman Jul 30, 2025
ceacce8
Address PR feedback and add `&& low(i) ==>`
henriman Aug 12, 2025
8a3278f
Merge branch 'sif-private-topology-underlay' into sif-private-topology
henriman Aug 12, 2025
0003f81
Remove `&& low(i) ==>` from one assertion not dealing with sensitivity
henriman Aug 12, 2025
27f66a5
Remove assumption for Gobra issue 831
henriman Aug 18, 2025
c72c877
Align contract clauses
henriman Sep 19, 2025
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
18 changes: 15 additions & 3 deletions private/topology/linktype.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/scionproto/scion/pkg/private/serrors"
//@ . "github.com/scionproto/scion/verification/utils/definitions"
//@ sl "github.com/scionproto/scion/verification/utils/slices"
//@ "github.com/scionproto/scion/verification/utils/sif"
)

// LinkType describes inter-AS links.
Expand All @@ -44,6 +45,7 @@ const (
Peer LinkType = 4
)

// @ requires low(l)
// @ decreases
func (l LinkType) String() string {
if l == Unset {
Expand All @@ -59,6 +61,7 @@ func (l LinkType) String() string {

// LinkTypeFromString returns the numerical link type associated with a string description. If the
// string is not recognized, an Unset link type is returned. The matching is case-insensitive.
// @ requires low(s)
// @ decreases
func LinkTypeFromString(s string) (res LinkType) {
var l /*@@@*/ LinkType
Expand All @@ -70,6 +73,7 @@ func LinkTypeFromString(s string) (res LinkType) {
return l
}

// @ requires low(l)
// @ ensures (l == Core || l == Parent || l == Child || l == Peer) == (err == nil)
// @ ensures err == nil ==> sl.Bytes(res, 0, len(res))
// @ ensures err != nil ==> err.ErrorMem()
Expand Down Expand Up @@ -97,13 +101,21 @@ func (l LinkType) MarshalText() (res []byte, err error) {
}
}

// @ requires acc(sl.Bytes(data, 0, len(data)), R15)
// @ requires low(len(data)) &&
// @ forall i int :: { sl.GetByte(data, 0, len(data), i) } 0 <= i && i < len(data) && low(i) ==>
// @ low(sl.GetByte(data, 0, len(data), i))
// @ preserves acc(l)
// @ preserves acc(sl.Bytes(data, 0, len(data)), R15)
// @ ensures acc(sl.Bytes(data, 0, len(data)), R15)
// @ ensures err != nil ==> err.ErrorMem()
// @ ensures low(err != nil)
// @ decreases
func (l *LinkType) UnmarshalText(data []byte) (err error) {
//@ unfold acc(sl.Bytes(data, 0, len(data)), R15)
//@ ghost defer fold acc(sl.Bytes(data, 0, len(data)), R15)
//@ unfold acc(sl.Bytes(data, 0, len(data)), R16)
//@ ghost defer fold acc(sl.Bytes(data, 0, len(data)), R16)
//@ assert forall i int :: { &data[i] } 0 <= i && i < len(data) ==>
//@ sl.GetByte(data, 0, len(data), i) == data[i]
//@ sif.LowSliceImpliesLowString(data, R16)
switch strings.ToLower(string(data)) {
case "core":
*l = Core
Expand Down
11 changes: 11 additions & 0 deletions verification/utils/sif/assumptions.gobra
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +gobra

package sif

// TODO: Once Gobra issue #832 is resolved, introduce body and prove this.
ghost
requires p > 0 && acc(b, p)
requires low(len(b)) && forall i int :: { &b[i] } 0 <= i && i < len(b) && low(i) ==> low(b[i])
ensures acc(b, p) && low(string(b))
decreases
func LowSliceImpliesLowString(b []byte, p perm)