Skip to content

Commit 0bcc8d0

Browse files
committed
vendor longfellow-zk
1 parent 6ac3349 commit 0bcc8d0

File tree

10 files changed

+822
-38
lines changed

10 files changed

+822
-38
lines changed

Makefile

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -394,22 +394,7 @@ ZK_DST := internal/verifier/zk
394394
ZK_LIB_DST := internal/verifier/zk/lib
395395
DOCKER_TAG_VERIFIER := docker.sunet.se/dc4eu/verifier:$(VERSION)
396396

397-
# Fetch ZK libraries
398-
zk:
399-
$(info Fetching Longfellow ZK)
400-
mkdir -p build
401-
if [ -d build/longfellow-zk ]; then \
402-
cd build/longfellow-zk && git pull; \
403-
else \
404-
git clone https://github.com/google/longfellow-zk.git build/longfellow-zk; \
405-
fi
406-
rm -rf $(ZK_DST)
407-
cp -r $(ZK_SRC) $(ZK_DST)
408-
cp -r $(ZK_LIB_SRC) $(ZK_LIB_DST)
409-
cp -r $(ZK_CERT_SRC) $(ZK_DST)
410-
411-
412-
docker-build-verifier: zk
397+
docker-build-verifier:
413398
$(info Building Docker image 'verifier')
414399
docker build -f dockerfiles/verifier.Dockerfile -t verifier .
415400
docker tag verifier ${DOCKER_TAG_VERIFIER}

dockerfiles/verifier.Dockerfile

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,38 @@
55
clang cmake libssl-dev libzstd-dev libgtest-dev \
66
libbenchmark-dev zlib1g-dev build-essential git
77

8-
WORKDIR /app/vc/internal/verifier/zk
9-
COPY ../internal/verifier/zk/lib ./lib
10-
COPY ../internal/verifier/zk/lib/circuits/mdoc/circuits ./server/circuits/LONGFELLOW_V1
8+
# 1. Clone the external dependency
9+
RUN git clone https://github.com/google/longfellow-zk.git /tmp/longfellow-zk
1110

11+
WORKDIR /tmp/longfellow-zk
1212
RUN CXX=clang++ cmake -D CMAKE_BUILD_TYPE=Release -S lib -B build \
13-
--install-prefix /app/vc/internal/verifier/zk/install && \
13+
--install-prefix /usr/local/zk-install && \
1414
cd build && make -j$(nproc) install
1515

1616
WORKDIR /app
1717
COPY . .
18-
19-
20-
RUN find /app -name "mdoc_zk.h" && find /app -name "*.a"
18+
# Ensure 'vendor' was created on host via `go mod vendor`
19+
COPY vendor/ ./vendor/
2120

2221
RUN --mount=type=cache,target=/root/.cache/go-build \
2322
CGO_ENABLED=1 \
24-
CGO_CFLAGS="-I/app/vc/internal/verifier/zk/install/include" \
25-
CGO_LDFLAGS="-L/app/vc/internal/verifier/zk/install/lib -lmdoc_static -lcrypto -lzstd -lstdc++" \
26-
GOOS=linux GOARCH=amd64 \
27-
go build -v -o /app/bin/vc_verifier ./cmd/verifier/main.go
28-
23+
CGO_CFLAGS="-I/usr/local/zk-install/include" \
24+
CGO_LDFLAGS="-L/usr/local/zk-install/lib -lmdoc_static -lcrypto -lzstd -lstdc++" \
25+
go build -mod=vendor -v -o /app/bin/vc_verifier ./cmd/verifier/main.go
26+
2927
# --- Stage 2: Final Runtime Image ---
3028
FROM docker.sunet.se/dc4eu/verifier:latest
3129

3230
USER root
3331
RUN apt update -y && apt install -y libssl3 libzstd1 zlib1g && rm -rf /var/lib/apt/lists/*
3432

33+
# Copy the binary
3534
COPY --from=builder /app/bin/vc_verifier /usr/local/bin/verifier
36-
COPY --from=builder /app/vc/internal/verifier/zk/server/circuits /app/vc/internal/verifier/zk/circuits/
37-
38-
COPY --from=builder /app/vc/internal/verifier/zk/install/lib /usr/local/lib/
39-
COPY ../internal/verifier/zk/certs.pem /app/vc/internal/verifier/zk/certs.pem
35+
COPY --from=builder /tmp/longfellow-zk/lib/circuits /app/vc/internal/verifier/zk/circuits/
4036

37+
# Copy compiled libraries
38+
COPY --from=builder /usr/local/zk-install/lib /usr/local/lib/
4139
RUN ldconfig
4240

43-
4441
WORKDIR /
45-
46-
ENTRYPOINT ["/usr/local/bin/verifier"]
47-
42+
ENTRYPOINT ["/usr/local/bin/verifier"]

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ require (
6464
gopkg.in/yaml.v2 v2.4.0
6565
gorm.io/gorm v1.31.1
6666
gotest.tools/v3 v3.5.2
67+
proofs/server/v2 v2.0.0
6768
)
6869

6970
require (
@@ -215,3 +216,5 @@ require (
215216
gopkg.in/yaml.v3 v3.0.1 // indirect
216217
nhooyr.io/websocket v1.8.17 // indirect
217218
)
219+
220+
replace proofs/server/v2 => /tmp/longfellow-zk/reference/verifier-service/server

pkg/model/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,15 @@ type Verifier struct {
468468
CredentialDisplay CredentialDisplayConfig `yaml:"credential_display,omitempty"`
469469
// Trust holds the trust evaluation configuration
470470
Trust TrustConfig `yaml:"trust,omitempty"`
471+
// ZKConfig is the longfellow-zk configuration
472+
ZK ZKConfig `yaml:"zk" validate:"required"`
473+
}
474+
475+
type ZKConfig struct {
476+
// Note the envconfig tags - this is how the loader finds them!
477+
CACertsPath string `yaml:"ca_certs_path" envconfig:"VERIFIER_ZK_CA_CERTS" validate:"required"`
478+
CircuitsPath string `yaml:"circuits_path" envconfig:"VERIFIER_ZK_CIRCUITS" validate:"required"`
479+
LibPath string `yaml:"lib_path" envconfig:"VERIFIER_ZK_LIB" validate:"required"`
471480
}
472481

473482
// TrustConfig holds configuration for key resolution and trust evaluation via go-trust.

vendor/modules.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,5 +1196,7 @@ gotest.tools/v3/internal/assert
11961196
gotest.tools/v3/internal/difflib
11971197
gotest.tools/v3/internal/format
11981198
gotest.tools/v3/internal/source
1199-
# nhooyr.io/websocket v1.8.17
1200-
## explicit; go 1.19
1199+
# proofs/server/v2 v2.0.0 => /tmp/longfellow-zk/reference/verifier-service/server
1200+
## explicit; go 1.24
1201+
proofs/server/v2/zk
1202+
# proofs/server/v2 => /tmp/longfellow-zk/reference/verifier-service/server

0 commit comments

Comments
 (0)