aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Devos <maximedevos@telenet.be>2023-01-10 01:52:11 +0100
committerMaxime Devos <maximedevos@telenet.be>2023-02-02 18:48:40 +0100
commit918c2fac18355c2fe30d7c2e064f27af76e1bf36 (patch)
tree0d57c07ac8744a2d397c89cb549d4b477d2428cc
parent86e6038bb51f80d08427acfaff4c2b661e248188 (diff)
downloadgnunet-scheme-918c2fac18355c2fe30d7c2e064f27af76e1bf36.tar.gz
gnunet-scheme-918c2fac18355c2fe30d7c2e064f27af76e1bf36.zip
WIP new construct + analyse
-rw-r--r--gnu/gnunet/fs/network.scm36
-rw-r--r--gnu/gnunet/fs/struct.scm2
2 files changed, 34 insertions, 4 deletions
diff --git a/gnu/gnunet/fs/network.scm b/gnu/gnunet/fs/network.scm
index 8de63c0..904a47e 100644
--- a/gnu/gnunet/fs/network.scm
+++ b/gnu/gnunet/fs/network.scm
@@ -1,6 +1,6 @@
1;#!r6rs 1;#!r6rs
2;; This file is part of Scheme-GNUnet 2;; This file is part of Scheme-GNUnet
3;; Copyright © 2022 GNUnet e.V. 3;; Copyright © 2022, 2023 GNUnet e.V.
4;; 4;;
5;; Scheme-GNUnet is free software: you can redistribute it and/or modify it 5;; Scheme-GNUnet is free software: you can redistribute it and/or modify it
6;; under the terms of the GNU Affero General Public License as published 6;; under the terms of the GNU Affero General Public License as published
@@ -19,13 +19,15 @@
19 19
20;; TODO: untested 20;; TODO: untested
21(define-library (gnu gnunet fs network) 21(define-library (gnu gnunet fs network)
22 (export construct-request-loc-signature analyse-request-loc-signature) 22 (export construct-request-loc-signature analyse-request-loc-signature
23 construct-response-loc-signature analyse-response-loc-signature)
23 (import (only (rnrs base) define values) 24 (import (only (rnrs base) define values)
24 (only (guile) begin define*) 25 (only (guile) begin define*)
25 (only (gnu extractor enum) value->index symbol-value) 26 (only (gnu extractor enum) value->index symbol-value)
26 (only (gnu gnunet message protocols) message-type) 27 (only (gnu gnunet message protocols) message-type)
27 (only (gnu gnunet fs struct) 28 (only (gnu gnunet fs struct)
28 /content-hash-key /:msg:fs:request-loc-signature) 29 /content-hash-key /:msg:fs:request-loc-signature
30 /:msg:fs:response-loc-signature)
29 (only (gnu gnunet fs uri) 31 (only (gnu gnunet fs uri)
30 content-hash-key-key ;; TODO rename 32 content-hash-key-key ;; TODO rename
31 content-hash-key-query 33 content-hash-key-query
@@ -72,4 +74,32 @@ message @var{message}."
72 (values (r% file-length) 74 (values (r% file-length)
73 (make-content-hash-key/share (s% content-hash-key)) 75 (make-content-hash-key/share (s% content-hash-key))
74 (r% expiration-time) 76 (r% expiration-time)
77 (r% purpose)))
78
79 (define*
80 (construct-response-loc-signature expiration-time signature peer
81 #:key (purpose %purpose-peer-placement))
82 "Create a new @code{/:msg:fs:response-loc-signature} message, for an EdDSA signature
83@var{signature} (as a readable @code{/eddsa-signature} bytevector slice) by @var{peer}
84(as a readable @code{/peer-identity} bytevector slice), expiring at @var{expiration-time}
85(TODO type)."
86 (construct
87 /:msg:fs:response-loc-signature
88 (=>! (header size) (%sizeof))
89 (=>! (header type)
90 (value->index
91 (symbol-value message-type msg:fs:response-loc-signature)))
92 (=>! (purpose) purpose)
93 (=>! (expiration-time) expiration-time)
94 (=>slice! (signature) signature)
95 (=>slice! (peer) peer)))
96
97 (define-analyser analyse-response-loc-signature
98 /:msg:fs:response-loc-signature
99 "Return the expiration time (TODO type), signature (as a slice of the message),
100peer identity (as a slice of the message) and the signature purpose corresponding to
101the @code{/:msg:fs:response-loc-signature} message."
102 (values (r% expiration-time)
103 (s% signature)
104 (s% peer)
75 (r% purpose))))) 105 (r% purpose)))))
diff --git a/gnu/gnunet/fs/struct.scm b/gnu/gnunet/fs/struct.scm
index 12e9874..e9f550b 100644
--- a/gnu/gnunet/fs/struct.scm
+++ b/gnu/gnunet/fs/struct.scm
@@ -1,5 +1,5 @@
1;; This file is part of Scheme-GNUnet. 1;; This file is part of Scheme-GNUnet.
2;; Copyright © 2003--2012, 2022 GNUnet e.V. 2;; Copyright © 2003--2012, 2022--2023 GNUnet e.V.
3;; 3;;
4;; Scheme-GNUnet is free software: you can redistribute it and/or modify it 4;; Scheme-GNUnet is free software: you can redistribute it and/or modify it
5;; under the terms of the GNU Affero General Public License as published 5;; under the terms of the GNU Affero General Public License as published