Skip to content

Commit

Permalink
chore: add afgo-ext vc status component.
Browse files Browse the repository at this point in the history
Signed-off-by: Volodymyr Kubiv <volodymyr.kubiv@euristiq.com>
  • Loading branch information
vkubiv committed Aug 22, 2023
1 parent 0b65ffb commit ea7eee5
Show file tree
Hide file tree
Showing 12 changed files with 1,875 additions and 21 deletions.
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ require (
github.com/go-jose/go-jose/v3 v3.0.1-0.20221117193127-916db76e8214
github.com/google/tink/go v1.7.0
github.com/google/uuid v1.3.0
github.com/hyperledger/aries-framework-go/component/log v0.0.0-20230417184158-344a7f82c4c2
github.com/hyperledger/aries-framework-go/test/component v0.0.0-20220322085443-50e8f9bd208b
github.com/hyperledger/aries-framework-go/component/log v0.0.0-20230427134832-0c9969493bd3
github.com/kawamuray/jsonpath v0.0.0-20201211160320-7483bafabd7e
github.com/mitchellh/mapstructure v1.5.0
github.com/multiformats/go-multibase v0.1.1
Expand All @@ -26,6 +25,7 @@ require (
github.com/stretchr/testify v1.8.1
github.com/tidwall/gjson v1.14.3
github.com/tidwall/sjson v1.1.4
github.com/trustbloc/did-go v0.0.0-20230822092335-dddc0073f25a
github.com/trustbloc/kms-crypto-go v0.0.0-20230817141224-c6cb8c6f1908
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/crypto v0.1.0
Expand All @@ -34,27 +34,26 @@ require (

require (
github.com/IBM/mathlib v0.0.3-0.20230605104224-932ab92f2ce0 // indirect
github.com/bluele/gcache v0.0.0-20190518031135-bc40bd653833 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.9.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/hyperledger/aries-framework-go/spi v0.0.0-20230516135652-20c4d4beb991 // indirect
github.com/hyperledger/aries-framework-go/spi v0.0.0-20230517133327-301aa0597250 // indirect
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 // indirect
github.com/hyperledger/ursa-wrapper-go v0.3.1 // indirect
github.com/kilic/bls12-381 v0.1.1-0.20210503002446-7b7597926c69 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/mr-tron/base58 v1.1.3 // indirect
github.com/multiformats/go-base32 v0.0.3 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/cachecontrol v0.1.0 // indirect
github.com/teserakt-io/golang-ed25519 v0.0.0-20210104091850-3888c087a4c8 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
golang.org/x/sys v0.11.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
Expand Down
26 changes: 12 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6Ro
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/bluele/gcache v0.0.0-20190518031135-bc40bd653833 h1:yCfXxYaelOyqnia8F/Yng47qhmfC9nKTRIbYRrRueq4=
github.com/bluele/gcache v0.0.0-20190518031135-bc40bd653833/go.mod h1:8c4/i2VlovMO2gBnHGQPN5EJw+H0lx1u/5p+cgsXtCk=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btcd v0.22.3 h1:kYNaWFvOw6xvqP0vR20RP1Zq1DVMBxEO8QN5d1/EfNg=
github.com/btcsuite/btcd v0.22.3/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y=
Expand Down Expand Up @@ -42,7 +40,6 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/go-jose/go-jose/v3 v3.0.1-0.20221117193127-916db76e8214 h1:w5li6eMV6NCHh1YVbKRM/gMCVtZ2w7mnwq78eNnHXQQ=
github.com/go-jose/go-jose/v3 v3.0.1-0.20221117193127-916db76e8214/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8=
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
Expand All @@ -59,12 +56,10 @@ github.com/google/tink/go v1.7.0/go.mod h1:GAUOd+QE3pgj9q8VKIGTCP33c/B7eb4NhxLcg
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hyperledger/aries-framework-go/component/log v0.0.0-20230417184158-344a7f82c4c2 h1:fKaNw6yi5PIXRDmEiOPNIErS6Mv92m03JcAE7wxj/Bk=
github.com/hyperledger/aries-framework-go/component/log v0.0.0-20230417184158-344a7f82c4c2/go.mod h1:CvYs4l8X2NrrF93weLOu5RTOIJeVdoZITtjEflyuTyM=
github.com/hyperledger/aries-framework-go/spi v0.0.0-20230516135652-20c4d4beb991 h1:1V0SW20i/MYefmu+O13/VNrzcO0fQ1FjTbGMFj2Bf5Y=
github.com/hyperledger/aries-framework-go/spi v0.0.0-20230516135652-20c4d4beb991/go.mod h1:oryUyWb23l/a3tAP9KW+GBbfcfqp9tZD4y5hSkFrkqI=
github.com/hyperledger/aries-framework-go/test/component v0.0.0-20220322085443-50e8f9bd208b h1:tq8CYv5vCJBSG2CjWKNt4l1BzZVJUy+GGF4U80fJV8o=
github.com/hyperledger/aries-framework-go/test/component v0.0.0-20220322085443-50e8f9bd208b/go.mod h1:HojN6OAh8ZtXBe5X2arcSOe1SLo5Dsjqto8ICjSLQ2g=
github.com/hyperledger/aries-framework-go/component/log v0.0.0-20230427134832-0c9969493bd3 h1:x5qFQraTX86z9GCwF28IxfnPm6QH5YgHaX+4x97Jwvw=
github.com/hyperledger/aries-framework-go/component/log v0.0.0-20230427134832-0c9969493bd3/go.mod h1:CvYs4l8X2NrrF93weLOu5RTOIJeVdoZITtjEflyuTyM=
github.com/hyperledger/aries-framework-go/spi v0.0.0-20230517133327-301aa0597250 h1:xohFDAv9+SbJD0t75QhSAdY0ZnxUf+k7wj2Jty+Sw7Y=
github.com/hyperledger/aries-framework-go/spi v0.0.0-20230517133327-301aa0597250/go.mod h1:oryUyWb23l/a3tAP9KW+GBbfcfqp9tZD4y5hSkFrkqI=
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 h1:B1Nt8hKb//KvgGRprk0h1t4lCnwhE9/ryb1WqfZbV+M=
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE=
github.com/hyperledger/ursa-wrapper-go v0.3.1 h1:Do+QrVNniY77YK2jTIcyWqj9rm/Yb5SScN0bqCjiibA=
Expand All @@ -84,10 +79,10 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY=
github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU=
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
github.com/mr-tron/base58 v1.1.3 h1:v+sk57XuaCKGXpWtVBX8YJzO7hMGx4Aajh4TQbdEFdc=
github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI=
github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA=
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE=
github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI=
github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4=
github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM=
github.com/multiformats/go-multibase v0.1.1 h1:3ASCDsuLX8+j4kx58qnJ4YFq/JWTJpCyDW27ztsVTOI=
Expand Down Expand Up @@ -125,10 +120,13 @@ github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/sjson v1.1.4 h1:bTSsPLdAYF5QNLSwYsKfBKKTnlGbIuhqL3CpRsjzGhg=
github.com/tidwall/sjson v1.1.4/go.mod h1:wXpKXu8CtDjKAZ+3DrKY5ROCorDFahq8l0tey/Lx1fg=
github.com/trustbloc/did-go v0.0.0-20230822092335-dddc0073f25a h1:mQnxuBw5WHr/ZRwzv4rfqM7XgELPillWVfaThUynDEg=
github.com/trustbloc/did-go v0.0.0-20230822092335-dddc0073f25a/go.mod h1:hXVAxkHGCGJx5/AsDI60mAMdI9Sydk4O7PRFecv9LzA=
github.com/trustbloc/kms-crypto-go v0.0.0-20230817141224-c6cb8c6f1908 h1:2vyfl6E2XN/hP4YOTbWrhlVu/Fq10xAydPSZYm5Kb4A=
github.com/trustbloc/kms-crypto-go v0.0.0-20230817141224-c6cb8c6f1908/go.mod h1:+yUiLndNRUZSwbgjKbUsr8D/x2zawgeH82KyccU3TiU=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
Expand Down
27 changes: 27 additions & 0 deletions status/api/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright Avast Software. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

// Package api contains dependency-injection interfaces for Credential Status validation clients.
package api

import (
"github.com/trustbloc/vc-go/verifiable"
)

// Validator holds handlers for validating a particular format of Status(Revocation) List VC.
type Validator interface {
ValidateStatus(vcStatus *verifiable.TypedID) error
GetStatusVCURI(vcStatus *verifiable.TypedID) (string, error)
GetStatusListIndex(vcStatus *verifiable.TypedID) (int, error)
}

// ValidatorGetter provides the matching Validator for a given credential status type.
type ValidatorGetter func(statusType string) (Validator, error)

// StatusListVCURIResolver resolves a VC StatusList Credential.
type StatusListVCURIResolver interface {
Resolve(statusListVCURL string) (*verifiable.Credential, error)
}
73 changes: 73 additions & 0 deletions status/internal/bitstring/bitstring.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Copyright Avast Software. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

// Package bitstring provides functions for operating on byte slices as if they are 0-indexed arrays of bits,
// packed 8 bits to a byte, LSB-first.
package bitstring

import (
"bytes"
"compress/gzip"
"encoding/base64"
"fmt"
)

const (
bitsPerByte = 8
one = 0x1
)

// Decode decodes a compressed bitstring from a base64URL-encoded string.
func Decode(src string) ([]byte, error) {
decodedBits, err := base64.RawURLEncoding.DecodeString(src)
if err != nil {
return nil, err
}

b := bytes.NewReader(decodedBits)

zipReader, err := gzip.NewReader(b)
if err != nil {
return nil, err
}

buf := new(bytes.Buffer)
if _, err := buf.ReadFrom(zipReader); err != nil {
return nil, err
}

return buf.Bytes(), nil
}

// BitAt returns the bit in the idx'th position (zero-indexed) in the given bitstring.
func BitAt(bitString []byte, idx int) (bool, error) {
nByte := idx / bitsPerByte
nBit := idx % bitsPerByte

if idx < 0 || nByte >= len(bitString) {
return false, fmt.Errorf("position is invalid")
}

bitValue := (bitString[nByte] & (one << nBit)) != 0

return bitValue, nil
}

// Encode gzips a bitstring and encodes it as a raw urlsafe base-64 string.
func Encode(bitString []byte) (string, error) {
var buf bytes.Buffer

w := gzip.NewWriter(&buf)
if _, err := w.Write(bitString); err != nil {
return "", err
}

if err := w.Close(); err != nil {
return "", err
}

return base64.RawURLEncoding.EncodeToString(buf.Bytes()), nil
}
Loading

0 comments on commit ea7eee5

Please sign in to comment.