1 00:00:00,800 --> 00:00:01,420 All right. 2 00:00:01,420 --> 00:00:03,180 Let's get started here. 3 00:00:04,160 --> 00:00:06,000 Welcome, everybody. 4 00:00:06,000 --> 00:00:07,500 I'm Sean Gilligan. 5 00:00:07,500 --> 00:00:11,340 My talk is Cypherpunk Java with Nix. 6 00:00:12,380 --> 00:00:17,360 Welcome to Nix Vegas 2025, the first Nix Vegas. 7 00:00:19,640 --> 00:00:21,980 My name is Sean Gilligan. 8 00:00:21,980 --> 00:00:27,840 You can find me on GitHub as msgilligan and my email is here, too. 9 00:00:28,340 --> 00:00:32,920 Feel free to reach out if you have any questions or comments. 10 00:00:33,180 --> 00:00:38,340 I will make this kind of interactive, so if you have a question, just let me know. 11 00:00:43,300 --> 00:00:46,600 So I'm going to talk a little bit about Cypherpunk principles. 12 00:00:46,600 --> 00:00:48,640 I think I'll be preaching to the choir. 13 00:00:48,880 --> 00:00:52,620 The disclaimer is I don't consider myself a Cypherpunk yet. 14 00:00:52,620 --> 00:00:56,140 I'm more of an aspiring Cypherpunk, but I'm trying. 15 00:00:56,900 --> 00:01:08,200 I'm going to talk a little bit about how I got to Nix and how it's kind of becoming more of a Cypherpunk has led me to Nix. 16 00:01:09,120 --> 00:01:25,560 I know that a lot of people in the Nix community and also in the Bitcoin community that I deal with a lot tend to be pretty hostile to Java, so I'm going to talk about what has Java done for us lately, and the answer is a lot. 17 00:01:26,520 --> 00:01:42,520 I'm going to talk about the some of the projects that I'm working on that I'm hoping that are both responsible for my transformation and that I'm hoping to to kind of deliver on these Cypherpunk principles. 18 00:01:43,500 --> 00:01:46,640 The first, there are two related projects. 19 00:01:46,640 --> 00:01:55,960 The first one is a cryptography library for elliptic curve cryptography with the wonderful name secp256k1jdk. 20 00:01:57,120 --> 00:02:04,120 There's also a library called BitcoinJ that I'm the junior co-maintainer of. 21 00:02:04,460 --> 00:02:18,300 And then I'm going to talk about how Nix solved some of the problems we're having in developing these libraries, and then I'm going to present an example that uses Nix derivations to do some builds. 22 00:02:24,910 --> 00:02:31,770 So how many people are familiar with Eric Hughes and the Cypherpunks manifesto? 23 00:02:32,430 --> 00:02:37,590 Okay, it's a famous document from 1993. 24 00:02:37,590 --> 00:02:40,990 It has the famous phrase, Cypherpunks write code. 25 00:02:41,130 --> 00:02:45,910 We publish our code so that our fellow Cypherpunks may practice and play with it. 26 00:02:45,910 --> 00:02:49,750 Our code is free for all to use worldwide. 27 00:02:50,070 --> 00:02:51,670 I wonder what he would think of Nix. 28 00:02:51,670 --> 00:02:53,090 I think he would like it. 29 00:02:53,090 --> 00:02:55,690 He's still around, I haven't asked him. 30 00:02:55,710 --> 00:02:57,300 I keep pushing the wrong button. 31 00:02:59,010 --> 00:03:01,410 What are Cypherpunk values? 32 00:03:01,410 --> 00:03:02,570 Privacy. 33 00:03:03,050 --> 00:03:08,610 They want to make privacy tools available and they want them to come from a trusted source. 34 00:03:08,610 --> 00:03:10,990 That's where Nix comes in. 35 00:03:11,690 --> 00:03:20,100 People want to have autonomy over their software and hardware and there's not much more autonomous than a Nix config. 36 00:03:22,280 --> 00:03:29,800 I left out the quote where he talks about software that you can play with. 37 00:03:29,800 --> 00:03:31,380 Did I edit that down? 38 00:03:34,380 --> 00:03:35,500 No, no. 39 00:03:35,620 --> 00:03:38,320 Cypherpunks may practice and play with it. 40 00:03:38,380 --> 00:03:41,640 That is also a very Nix-like principle. 41 00:03:43,220 --> 00:03:51,380 I really loved the art and the whole concept of the great tree that they were using with Nix Vegas. 42 00:03:51,380 --> 00:04:01,960 So I wore my existing Yggdrasil t-shirt and now I have a new one that I got from the conference. 43 00:04:01,960 --> 00:04:03,400 It makes me really happy. 44 00:04:03,560 --> 00:04:15,040 One of the cool things about Nix, as most of you know, is it has one of the largest, the largest library of open source software of all the package managers. 45 00:04:15,220 --> 00:04:21,300 And that's what they were calling, first time I've heard it was in reading about this conference, the great tree. 46 00:04:23,810 --> 00:04:34,610 Another excerpt from the Cypherpunk manifesto that's near and dear to my heart is where he talks about we need anonymous systems with electronic money. 47 00:04:37,850 --> 00:04:40,770 So I'm a Unix person at heart. 48 00:04:40,770 --> 00:04:48,910 I did my undergrad at UC Berkeley and UC Santa Cruz and Unix and C are kind of in my DNA. 49 00:04:48,910 --> 00:04:53,970 But I also became a Macintosh developer in the early days of Macintosh. 50 00:04:54,090 --> 00:05:00,390 And it was really hard for me to not have Unix underneath this beautiful GUI that they had. 51 00:05:00,390 --> 00:05:13,570 And now, of course, I'm on Mac OS X and I use Mac OS X and I use Nix because it runs on both Mac and Darwin. 52 00:05:13,570 --> 00:05:18,490 So all my demos are going to be on Darwin and Linux. 53 00:05:18,810 --> 00:05:26,770 I actually played with Darwin when it was an open source operating system that you could install before Apple backed away from that. 54 00:05:28,430 --> 00:05:37,590 So when I started working on Bitcoin J, the lead developer, Andreas Schilbach, had made some decisions that really frustrated me. 55 00:05:37,590 --> 00:05:43,630 The first of which was there were no binaries allowed in the repository. 56 00:05:44,150 --> 00:05:49,250 And for those of you that are Java developers, I don't I think there's at least one or two here. 57 00:05:49,250 --> 00:05:54,710 You may be familiar with like the Gradle wrapper, which is a binary used to bootstrap your build. 58 00:05:54,710 --> 00:05:56,970 Not allowed in Bitcoin J. 59 00:05:57,910 --> 00:06:14,470 The second thing is that he insisted that everything be able to build according to Debian free software guidelines, which meant using this ancient version of Gradle known as FrankenGradle that's included with Debian. 60 00:06:14,470 --> 00:06:21,010 It's actually a build of Gradle 4.4 when the latest version is Gradle 9. 61 00:06:21,610 --> 00:06:27,250 The reason is that Gradle now needs Kotlin, and Kotlin is really hard to bootstrap. 62 00:06:27,410 --> 00:06:29,510 And Gradle is really hard to bootstrap. 63 00:06:29,510 --> 00:06:36,310 So they stick with this ancient version and they patch it to make it work with the newer JDKs. 64 00:06:38,210 --> 00:06:41,350 Now, of course, Nix is going to solve this, right? 65 00:06:41,690 --> 00:06:56,810 But so these are some of the things that led me more to the Cypherpunk world, working with Andreas, contributing to Bitcoin J, and dealing with some of these issues around Java that aren't very friendly to 66 00:07:00,030 --> 00:07:02,030 the free software world. 67 00:07:04,230 --> 00:07:07,930 All right, I'm going to take a little detour and talk about modern Java. 68 00:07:09,170 --> 00:07:13,650 A lot's changed between 2014 and now. 69 00:07:14,610 --> 00:07:21,690 As of Friday, Java 25 went to release candidate. 70 00:07:22,410 --> 00:07:30,930 For the last 10 years or so, they've been doing a new release every six months, and they've really done a nice job. 71 00:07:30,930 --> 00:07:48,710 I'm not a fan of Oracle, the corporation, but I will say that they've kept their good engineers, they've given them a lot of autonomy to do the right thing, and they've really cleaned up a lot of long-standing issues with Java. 72 00:07:48,710 --> 00:07:50,750 Things that I thought I'd never see fixed. 73 00:07:52,110 --> 00:08:02,470 They put out a new long-term support release every two years, Java 25 will be the long-term support release. 74 00:08:02,470 --> 00:08:04,160 It's coming out in September. 75 00:08:04,590 --> 00:08:07,370 It's not numbered by year. 76 00:08:07,430 --> 00:08:12,730 There will be a 26 in early 26, and a 27 in September 26. 77 00:08:13,710 --> 00:08:19,250 There's an algebraic formula where you subtract and multiply by two. 78 00:08:23,430 --> 00:08:27,470 I'm just going to run through all the features that have been added in the last 10 years. 79 00:08:27,470 --> 00:08:31,790 I'm showing which version of Java is listed. 80 00:08:32,850 --> 00:08:41,150 I'm showing the LTS version that added that feature, not when it was previewed or when it was first released in a general availability. 81 00:08:41,210 --> 00:08:50,770 So with 8, we got lambdas, streams, default methods and interface, optional type, which is like a promise. 82 00:08:51,870 --> 00:08:59,810 It's also for the functional programmers, it's actually a monad. 83 00:09:00,550 --> 00:09:08,390 New time API, 11 added modules, a new HTTP API, reactive streams. 84 00:09:08,470 --> 00:09:10,850 You can use VAR if you want to. 85 00:09:10,850 --> 00:09:15,370 A REPL and Shebang execution are now supported. 86 00:09:16,070 --> 00:09:25,490 JLink lets you build a custom JRE just for your project, and it's used nicely in mixed packages these days. 87 00:09:26,770 --> 00:09:32,230 They added switch expressions, which are a lot like the match expression in Rust. 88 00:09:32,470 --> 00:09:35,750 They also have pattern matching that works with them. 89 00:09:36,370 --> 00:09:45,630 Records are immutable objects without a lot of the verbosity of Java beans, and immutability and verbosity of Java beans forever banished. 90 00:09:46,270 --> 00:09:53,090 Sealed classes allow you to do things like Rust enums, if you're a Rust developer. 91 00:09:53,990 --> 00:09:58,850 They created a packaging tool, which can be used to bundle a JDK. 92 00:09:59,170 --> 00:10:02,230 You have multiline text blocks. 93 00:10:02,370 --> 00:10:07,090 Hex format is like a little thing, but damn it, why did it take them so long to add that? 94 00:10:07,970 --> 00:10:17,430 Virtual threads is like go routines, pattern matching in switch, snippets in your code, sequence collections. 95 00:10:17,430 --> 00:10:19,370 Panama is a really important thing. 96 00:10:19,370 --> 00:10:21,830 It's known as the foreign function and memory API. 97 00:10:21,830 --> 00:10:24,690 It became final in Java 22. 98 00:10:24,690 --> 00:10:36,450 It's a new way of calling native code from your Java, and I'm going to talk about that, because my demo uses it very effectively, I think. 99 00:10:36,470 --> 00:10:42,730 It went final in Java 22, and it's becoming long-term available in 25. 100 00:10:43,970 --> 00:10:51,730 The nice thing is you don't have to... if anybody's used JNI, you know that it's very painful, it's tedious, and it's error-prone. 101 00:10:51,830 --> 00:10:59,210 The Panama API, which I won't have time to get into, really makes it a lot simpler and a lot nicer. 102 00:10:59,210 --> 00:11:16,270 And it also works pretty well with Nix when you bring in a dynamic library as a Nix dependency, you can link to it and use it directly versus the older JNI way, you typically bundle things inside of a jar. 103 00:11:17,550 --> 00:11:24,550 They also finally simplified Hello World with something called implicit classes and instance main methods. 104 00:11:25,930 --> 00:11:28,310 They've added structured concurrency. 105 00:11:28,310 --> 00:11:37,460 There's a vector API that's early access, and Valhalla adds value types where you're able to not create things on the heap. 106 00:11:38,340 --> 00:11:44,760 And then GraalVM is the native compilation tool. 107 00:11:44,760 --> 00:11:51,640 It includes a native compilation tool, it also has polyglot language support, and a Java VM actually written in Java. 108 00:11:51,640 --> 00:11:59,600 It's a pretty advanced piece of compiler technology, and I can't say that I really understand it, but I do really like the native image. 109 00:11:59,600 --> 00:12:14,780 And so the example that I'm going to give is something compiled with GraalVM to generate a native image, and then it's using a native C library that's linked with the Panama FFM API. 110 00:12:15,620 --> 00:12:18,320 They've also removed a lot of stuff. 111 00:12:18,320 --> 00:12:19,820 Applets are gone. 112 00:12:19,820 --> 00:12:26,200 They removed the security manager because it wasn't... well, they removed the security manager. 113 00:12:26,200 --> 00:12:41,860 They also removed the secp256k1 elliptic cryptography, elliptic curve cryptography curve, but I have added it back using a library from Bitcoin called blipsec256k1. 114 00:12:43,160 --> 00:13:05,280 Okay, so I'm going to go through this fairly quickly, but the example that I'm using and a project I've been working on is to create a new reference implementation of the secp256k1 curve for the JDK and JVM languages. 115 00:13:06,800 --> 00:13:12,160 It's based on this C API, which is wrapped with the foreign function manager. 116 00:13:12,840 --> 00:13:19,360 It uses the standards for efficient cryptography group secp256k1 curve. 117 00:13:19,560 --> 00:13:28,580 The Java library is modeled after the C library because they did a really nice job of making it hard to shoot yourself in the foot. 118 00:13:28,620 --> 00:13:34,680 And so with Java, we're just able to simplify it and make it a little less verbose. 119 00:13:34,680 --> 00:13:37,000 We're using functional return types. 120 00:13:37,000 --> 00:13:37,520 We're using... 121 00:13:37,520 --> 00:13:44,320 you know, we've got garbage collection, so you don't have to worry about pointers and things like that. 122 00:13:45,240 --> 00:13:51,100 The interesting thing that we've done with secp256k1 is we have two implementations. 123 00:13:51,100 --> 00:14:00,200 One that uses this best-of-breed C library, and another that uses a library known as bouncycastle. 124 00:14:01,080 --> 00:14:11,660 Not going to demo the bouncycastle today because I'm really focused on the native thing because that's kind of... it's been my main focus and it's most interesting from a Nix perspective. 125 00:14:13,380 --> 00:14:22,380 So the libsecp library was created by the Bitcoin core group after they moved away from OpenSSL. 126 00:14:24,060 --> 00:14:28,220 I'm going to go through this pretty quickly because I think we're limited on time. 127 00:14:37,600 --> 00:14:40,540 So these are the library jars. 128 00:14:40,540 --> 00:14:43,300 You can see they're pretty... they're probably a little bit bigger now. 129 00:14:44,160 --> 00:14:55,770 But there's an API jar that you use, and then there's the foreign function, the FFM implementation, and there's a bouncycastle implementation. 130 00:14:56,780 --> 00:15:04,710 When you compile against it, you just compile against the API jar, and then at runtime you can deploy it either way. 131 00:15:09,710 --> 00:15:21,910 The native one, of course, requires 22 or later, and with 25 being the LTS, we're actually going to just set the requirement to be 25. 132 00:15:22,050 --> 00:15:25,950 This is the example program that I'm going to show. 133 00:15:25,950 --> 00:15:30,610 It basically generates a key. 134 00:15:30,610 --> 00:15:34,810 It's based on the C example from the C library. 135 00:15:34,810 --> 00:15:40,810 It basically generates a secret key, generates a public key, signs and verifies. 136 00:15:45,490 --> 00:15:50,970 This is the signing code. 137 00:15:53,440 --> 00:15:55,480 This is the verification. 138 00:15:55,480 --> 00:16:00,380 This is not using the simplified hello world yet. 139 00:16:02,140 --> 00:16:08,580 Because one of the things is that JDK 25 is not available in Nix yet. 140 00:16:08,580 --> 00:16:16,820 I actually created a fork and put in the GraalVM 25 early access, and I'm using that for this demo. 141 00:16:16,820 --> 00:16:32,360 But one of the things I'm hoping to personally contribute to the Nix ecosystem is to help get new releases of Java supported faster so that packages can migrate so that we can start debugging them earlier. 142 00:16:36,400 --> 00:16:48,020 BitcoinJ is a library that is about 15 years old, and when I started working on it, I realized that it really needed some major updates. 143 00:16:48,020 --> 00:17:04,120 So we've been kind of modernizing it along the principles of modern functional style Java, while maintaining a lot of backward compatibility, because one of the major use cases has been Android wallets. 144 00:17:04,120 --> 00:17:23,220 Andreas really feels that it should support a wide variety of inexpensive Android phones, and he holds us back so that it can be used all over the world from people that maybe can't afford newer phones. 145 00:17:23,980 --> 00:17:28,120 And it's available in the... 146 00:17:29,520 --> 00:17:33,100 I'm drawing a blank on the name of the app store, the Android app store. 147 00:17:34,500 --> 00:17:36,140 No, not the Play Store. 148 00:17:36,400 --> 00:17:37,420 It's F-Droid. 149 00:17:37,420 --> 00:17:38,900 It's available in F-Droid. 150 00:17:42,740 --> 00:17:45,600 There's a few apps powered in it. 151 00:17:45,600 --> 00:17:50,200 The Bitcoin Wallet by Andreas Schilbach is one of the major drivers. 152 00:17:50,200 --> 00:17:52,960 There's a Bisk peer-to-peer networking app. 153 00:17:54,740 --> 00:17:57,540 There's also... this is the history of the project. 154 00:17:57,540 --> 00:17:59,360 I'm going to skip over that. 155 00:18:00,440 --> 00:18:05,800 Release 18 is going to have the new SecP library. 156 00:18:06,980 --> 00:18:09,500 All right, so how does Nix help? 157 00:18:12,140 --> 00:18:20,200 How many people here are familiar with the way Maven repositories and Java packaging is done? 158 00:18:20,480 --> 00:18:22,360 Two, okay. 159 00:18:22,400 --> 00:18:23,200 It's... 160 00:18:23,200 --> 00:18:26,460 No, actually not. 161 00:18:26,460 --> 00:18:44,540 I actually think that Maven and Gradle may have their problems, but having pre-built binaries that you can pull based on a coordinate of group, artifact, and version works pretty well. 162 00:18:44,540 --> 00:18:52,460 And it's actually very similar to Nix, with one major thing that's missing, being able to rebuild it from source. 163 00:18:53,500 --> 00:18:58,580 But, you know, a lot of times you get into these dependency hell situations with... 164 00:18:59,860 --> 00:19:03,200 we try to get everything onto the same dependency. 165 00:19:03,720 --> 00:19:05,100 Gradle... I mean, not Gradle. 166 00:19:05,100 --> 00:19:18,140 The Maven repository system, like Nix, allows each app to declare its dependencies and have its own tool chain that can essentially be version locked. 167 00:19:19,760 --> 00:19:31,260 So when you bring that into Maven, you get some mismatch issues because they work differently, and there's some hacks to resolve that. 168 00:19:31,260 --> 00:19:33,520 And I'll show that briefly. 169 00:19:35,160 --> 00:19:39,640 As just before I do the demo. 170 00:19:39,760 --> 00:19:48,280 One of the other things that's interesting to me about Nix is that source is the metadata called source provenance. 171 00:19:48,280 --> 00:19:50,460 Is everybody familiar with that? 172 00:19:52,500 --> 00:19:53,440 Yeah? 173 00:19:53,440 --> 00:19:54,160 Yeah? 174 00:19:54,160 --> 00:19:56,700 So in the package... I'll go over it briefly. 175 00:19:56,700 --> 00:20:06,320 In the package metadata, there's a metadata field called source provenance, and there's a handful of values that you can use for it. 176 00:20:06,360 --> 00:20:08,900 So you can say it's source code. 177 00:20:08,900 --> 00:20:10,180 It's built from the source. 178 00:20:10,180 --> 00:20:13,860 You can say that it's a precompiled binary. 179 00:20:13,860 --> 00:20:20,820 There's also a category called bytecode, which is what you'll use if you pull in a precompiled Java jar library. 180 00:20:21,940 --> 00:20:31,780 One of the reasons I think for Nix's success is that it does allow you to bring in these things that were built as binaries. 181 00:20:31,780 --> 00:20:35,620 That's why the package repository is so large. 182 00:20:35,620 --> 00:20:47,700 But if you really want bootstrapability, which for me is the holy grail and something that I'm pursuing, then you want to see more things having source provenance. 183 00:20:47,700 --> 00:20:55,600 So for example, for this demo, I'm using a GraalVM build that's not built from source. 184 00:20:56,260 --> 00:20:59,660 OpenJDK is built from source. 185 00:20:59,660 --> 00:21:06,920 There's also Zulu and Temarin, which are other builds of the JDK that are brought in as binaries. 186 00:21:09,040 --> 00:21:19,000 So one of my long-term goals is to see more bootstrapability in the components that I'm working on. 187 00:21:23,690 --> 00:21:26,250 All right. 188 00:21:31,090 --> 00:21:37,890 So I originally got this working with a bit of a hack. 189 00:21:37,890 --> 00:21:54,690 If you don't want to do a full Nix package, you can use a dev shell and just say... and just call... and just run the dev shell to do your build. 190 00:21:54,690 --> 00:21:59,270 I do that in GitHub actions, for example. 191 00:21:59,490 --> 00:22:03,830 But seeing Fareed's demo yesterday, I said... God damn it. 192 00:22:03,930 --> 00:22:04,930 I'm gonna stay. 193 00:22:04,930 --> 00:22:13,590 I'm gonna convert this to actually being a full Nix package, which I basically did with a few caveats. 194 00:22:13,590 --> 00:22:15,010 This thing keeps rotating. 195 00:22:21,130 --> 00:22:22,790 Was there a clamp? 196 00:22:23,050 --> 00:22:23,790 Yeah. 197 00:22:34,510 --> 00:22:35,910 Thank you. 198 00:22:38,110 --> 00:22:40,830 Can everybody see this? 199 00:22:41,990 --> 00:22:42,810 All right. 200 00:22:42,810 --> 00:22:49,230 So this is a little bit of a hack , because this is my first time doing this, actually, for real. 201 00:22:49,230 --> 00:22:54,050 But I have two packages of the same utility. 202 00:22:54,050 --> 00:22:58,010 Again, it's that Schnorr signature example. 203 00:22:58,010 --> 00:22:59,690 I have one build that uses... 204 00:23:00,990 --> 00:23:04,650 that generates the Java bytecode and runs it with the JIT. 205 00:23:04,650 --> 00:23:08,570 And I have another that compiles it completely native to C. 206 00:23:09,370 --> 00:23:15,190 I didn't use Flake Utils, so right now it only works on R64 Darwin. 207 00:23:15,190 --> 00:23:20,750 But I have tested some of this on Linux and on x86. 208 00:23:24,310 --> 00:23:38,970 So because the build is done with Gradle, I mentioned there's this thing called the... there's this extra step called fetch steps that pulls the jars down and basically version locks them. 209 00:23:38,970 --> 00:23:43,430 I think it's called a fixed output derivation, I believe. 210 00:23:43,910 --> 00:23:44,970 Yeah. 211 00:23:46,750 --> 00:23:54,130 So you have to run like a pre-step to build this deps.json file. 212 00:23:56,310 --> 00:24:01,110 And then it runs the Gradle task to do the build. 213 00:24:02,070 --> 00:24:08,390 And then in the install phase, it just copies the jars and then it makes a wrapper. 214 00:24:08,430 --> 00:24:18,430 Note that this is using the Java module system, which is the newer way of deploying... of running Java. 215 00:24:18,430 --> 00:24:28,730 It provides more tightly, you know, tighter boundaries and access control between modules, which I think is quite good for security. 216 00:24:28,730 --> 00:24:42,090 For example, you can see in here that it specifically enables which modules are allowed to call native code. 217 00:24:42,270 --> 00:24:52,910 One of the things that's been added to Java recently is this whole initiative around secure by default or integrity by default. 218 00:24:52,990 --> 00:25:00,230 So you now have to, if anything's going to access native code, you have to explicitly permit it when you compile your app. 219 00:25:00,230 --> 00:25:09,370 So in theory, this could provide some protection against a supply chain attack where you bring in another module that tries to do something fishy. 220 00:25:09,370 --> 00:25:14,290 If it's not enabled to talk to your native libraries, it won't be able to. 221 00:25:24,530 --> 00:25:35,730 This one here is the build of the native package, which also uses Gradle, but it uses a different Gradle task, which does the native compile. 222 00:25:36,110 --> 00:25:41,330 And then in the install phase, I learned a few things about this. 223 00:25:42,270 --> 00:25:49,710 It actually creates a, it actually uses wrap program to create a link to the library. 224 00:25:49,710 --> 00:26:03,710 You can use patch elf or there's something on the Mac, I forget what it's called, an equivalent thing on the Mac, but you can't use that with the GraalVM code that calls a native image because it uses DLOpen. 225 00:26:03,710 --> 00:26:07,650 So the actual library name isn't there in the executable. 226 00:26:07,650 --> 00:26:11,190 So you have to use this technique of, oh, here it is. 227 00:26:11,190 --> 00:26:13,170 You can see I haven't commented out. 228 00:26:13,310 --> 00:26:15,210 Install name tool won't work. 229 00:26:15,210 --> 00:26:17,730 You have to use a wrap program. 230 00:26:17,950 --> 00:26:28,150 There are ways of telling native image to build a more static executable, and I'm going to look into that in the future. 231 00:26:28,210 --> 00:26:34,630 But for this current build, at least, this wrap program was the way to go. 232 00:26:59,610 --> 00:27:00,410 Okay. 233 00:27:02,550 --> 00:27:08,610 So I thought I'd run, I showed that these examples actually run. 234 00:27:08,970 --> 00:27:12,170 First we will run, can everybody see this or should I make it bigger? 235 00:27:12,970 --> 00:27:14,070 A little bigger? 236 00:27:24,490 --> 00:27:35,910 So you can see when I run the Schnorr example, which is the one that actually uses the JVM, it runs in about 186 milliseconds. 237 00:27:39,870 --> 00:27:47,670 And the output's the same, but if I run it, if I run the native version, we're down to 35 milliseconds. 238 00:27:49,310 --> 00:27:56,930 And then the other thing I was going to show is the, is what the wrappers look like. 239 00:27:56,930 --> 00:28:02,010 So this is the wrapper for the JVM version. 240 00:28:02,010 --> 00:28:13,950 You can see that on the Mac, OpenJDK actually maps to Zulan, and you can see that it's directly pulling it from the Nix store. 241 00:28:13,970 --> 00:28:19,170 You can see the enable native access for just the FFM module that I mentioned. 242 00:28:19,170 --> 00:28:23,310 And you can see the library, you can see the library paths. 243 00:28:25,050 --> 00:28:28,630 And that's how, that's how the native version is run. 244 00:28:30,130 --> 00:28:35,390 For, for the, I'm sorry, that's how the JIT version is run. 245 00:28:35,390 --> 00:28:49,870 For the native version, you can see that it's setting up this dynamic load library path to the native C library in, in the Nix store, and then running based upon that. 246 00:28:50,610 --> 00:28:59,490 So, so what you're seeing when, when, when this runs is you're seeing natively compiled Java calling the Panama FFM 247 00:29:02,790 --> 00:29:07,610 capability , which then calls a natively compiled library. 248 00:29:08,890 --> 00:29:14,930 And built with all the native stuff being pulled in via Nix, which is really nice. 249 00:29:15,650 --> 00:29:20,930 So this is maybe the future of Cypherpunk Java. 250 00:29:21,990 --> 00:29:23,810 Any questions? 251 00:29:35,070 --> 00:29:36,210 All right. 252 00:29:37,230 --> 00:29:38,890 Oh, 253 00:29:50,730 --> 00:29:53,290 that's a really good question. 254 00:29:53,290 --> 00:29:54,570 Let me restate the question. 255 00:29:54,570 --> 00:30:04,710 The question is, if some organization took this on, would there be a way to replace the public Maven repository with the Nix cache? 256 00:30:09,430 --> 00:30:11,210 Or your local Maven? 257 00:30:11,430 --> 00:30:15,450 That, that's a, that's a great question, and I think about that a lot. 258 00:30:16,390 --> 00:30:22,930 I, I, you can, you can do it yourself for a small project using Nix. 259 00:30:22,970 --> 00:30:24,870 I've, I've played around with that. 260 00:30:24,870 --> 00:30:26,850 I think Fareed has done that. 261 00:30:29,950 --> 00:30:34,650 But to, to try to move the entire ecosystem would be really difficult. 262 00:30:38,090 --> 00:30:55,590 But maybe some, maybe some subset, you know, I'm wondering if, you know, if there could be some, you know, more, like, like, for example, one of the things I've done with the Secp JDK library is I've, and BitcoinJ, both of them, I've really worked hard to minimize dependencies. 263 00:30:55,830 --> 00:31:10,510 So Secp, you know, has the dependency on the C library, and it has only one other dependency, which is something called jspecify, which actually gives you really good null annotations, almost as good as Kotlin. 264 00:31:10,510 --> 00:31:12,670 And it's interoperable with Kotlin. 265 00:31:12,670 --> 00:31:14,630 So it's, it's, it's really nice. 266 00:31:14,630 --> 00:31:21,550 But with only those two dependencies, I do have the option of just pulling them in directly from Nix. 267 00:31:21,550 --> 00:31:29,550 The thing is, you also, if, if you publish a Java library, you also want to support the non-Nix Java community. 268 00:31:29,550 --> 00:31:37,030 So, you know, one of my goals with the Secp library is to do, is to use Nix for the reference build. 269 00:31:37,090 --> 00:31:46,230 BitcoinJ, because I'm the junior maintainer, I, I, I defer to Andreas, who likes to do that using Debian and Podman. 270 00:31:46,270 --> 00:31:52,030 But, but I would like to be able to do a reference build of the Secp library using Nix. 271 00:31:52,030 --> 00:31:57,830 It should be, you know, it should be reproducible with other build tools, if you set all your options right. 272 00:31:58,330 --> 00:32:12,070 But, but, you know, would it be possible to create something that, that sort of looks like a Maven repository, more, sort of more dynamically, and not use this man-in-the-middle deps.json technique? 273 00:32:12,630 --> 00:32:15,430 That's something I'd, I'd like to, to learn more about. 274 00:32:15,430 --> 00:32:20,470 And, and, you know, once I, you know, maybe in a year or so, it's something I might look at a little. 275 00:32:20,470 --> 00:32:25,250 And if anybody has any ideas about that, please, please, you know, I'd love to chat. 276 00:32:27,770 --> 00:32:29,230 Any other questions? 277 00:32:31,610 --> 00:32:32,170 Okay. 278 00:32:32,170 --> 00:32:32,450 Thank you. 279 00:32:32,450 --> 00:32:33,490 Thank you, everybody.