00:01:49 | * | byanka joined #nim |
00:04:12 | FromDiscord | <Yepoleb> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1059259611179393114): i was hoping to avoid the explicit slicing ☹️ |
00:04:49 | * | ixmpp quit (Remote host closed the connection) |
00:04:49 | * | droidrage quit (Remote host closed the connection) |
00:04:49 | * | qwestion quit (Remote host closed the connection) |
00:06:06 | * | ixmpp joined #nim |
00:12:54 | FromDiscord | <Yepoleb> can i somehow use the parameter style object initialization with new? I am trying to do this `var x = new Foo(a: 1, b: 2)`. I know how to do it with manually assigning each field. |
00:13:13 | FromDiscord | <Elegantbeef> `Foo(a: 1, b: 2)` works for ref object |
00:13:28 | FromDiscord | <Elegantbeef> if it's not a ref obj you can do `(ref Foo)(a: 1, b: 2)` |
00:14:00 | FromDiscord | <Yepoleb> this implicitly calls new? |
00:14:13 | FromDiscord | <Elegantbeef> Yes object constructors for ref objects heap allocate |
00:16:22 | FromDiscord | <Yepoleb> perfect, thanks! |
00:25:04 | * | azimut joined #nim |
00:30:35 | FromDiscord | <@thatrandomperson5-6310e3b26da03> > ↵> Is `ActiveWorker` a ref object?↵> Is it supposed to be? |
00:31:18 | FromDiscord | <Elegantbeef> It should be since you're storing the address of a vlaue |
00:51:06 | FromDiscord | <@thatrandomperson5-6310e3b26da03> It doesn’t fix the problem |
00:57:33 | * | wallabra joined #nim |
01:09:23 | * | wallabra_ joined #nim |
01:09:53 | * | wallabra quit (Ping timeout: 246 seconds) |
01:10:19 | * | wallabra_ is now known as wallabra |
01:49:24 | FromDiscord | <Iliketwertles> sent a code paste, see https://play.nim-lang.org/#ix=4k8V |
01:49:27 | FromDiscord | <Iliketwertles> what does this mean? |
01:50:53 | FromDiscord | <Iliketwertles> i dont think the code thats cut out is important to the error but idk https://media.discordapp.net/attachments/371759389889003532/1059287635346083850/screenshot_2023-01-01-205031.png |
01:50:56 | FromDiscord | <Rika> You’re trying to call a variable? |
01:51:12 | FromDiscord | <Rika> Second line in the screen shot |
01:51:17 | FromDiscord | <Rika> Inside the format string |
01:51:22 | FromDiscord | <Rika> You have parentheses |
01:51:29 | FromDiscord | <Rika> (edit) "You have ... parentheses" added "extra" |
01:51:46 | FromDiscord | <Iliketwertles> oh :FacePalm: |
01:51:49 | FromDiscord | <Iliketwertles> thanks |
01:59:40 | * | arkurious quit (Quit: Leaving) |
02:50:35 | * | azimut quit (Ping timeout: 255 seconds) |
03:13:37 | NimEventer | New thread by GavinRay: How does the `nimsuggest` LSP work with respect to UFCS support in Nim?, see https://forum.nim-lang.org/t/9789 |
03:22:26 | * | jvinet quit (Remote host closed the connection) |
03:47:45 | * | wallabra quit (Ping timeout: 260 seconds) |
04:14:28 | * | pbsds quit (Quit: The Lounge - https://thelounge.chat) |
04:15:29 | * | pbsds joined #nim |
04:43:41 | * | wallabra joined #nim |
05:07:48 | NimEventer | New post on r/nim by His_son: Noob question about storing data, see https://reddit.com/r/nim/comments/1013ytj/noob_question_about_storing_data/ |
07:07:09 | * | rockcavera quit (Remote host closed the connection) |
07:14:57 | FromDiscord | <jos> In reply to @Elegantbeef "https://github.com/yglukhov/iface": btw is this like not on nimble or something |
07:22:20 | * | kenran joined #nim |
07:22:41 | * | kenran quit (Remote host closed the connection) |
07:52:39 | * | azimut joined #nim |
08:00:30 | * | PMunch joined #nim |
08:25:51 | FromDiscord | <xoich (xoich)> hello, is there an Either type in nim? It's like Option, but with the possibility to specify an error if you can't return the value. Considering that nim discourages exceptions it would seems better to use something like this rather than raising. |
08:27:16 | FromDiscord | <Clonkk> `std/options` ecists |
08:27:18 | FromDiscord | <Clonkk> exists\ |
08:27:43 | FromDiscord | <xoich (xoich)> I thought you couldn't specify an error with that though? |
08:28:27 | FromDiscord | <Clonkk> Well you can always set the option to None to specify errors |
08:28:30 | FromDiscord | <Clonkk> Otherwise you have https://github.com/arnetheduck/nim-result |
08:30:29 | FromDiscord | <xoich (xoich)> I think nim-result is exactly what I wanted, thanks! |
08:32:30 | FromDiscord | <xoich (xoich)> I was hoping to find it in the stdlib, but ok |
09:22:25 | * | wallabra quit (Quit: ZNC 1.8.2 - https://znc.in) |
09:39:17 | FromDiscord | <voidwalker> less and less hope to find the good stuff in the stdlib. |
09:40:30 | FromDiscord | <voidwalker> in the future, it might be that it will only be used to learn nim. for real programs, use aweseomelib |
09:59:25 | PMunch | I wouldn't be opposed to creating a meta-package which depends on all the parts being moved out of the stdlib and then have that meta-package be installed by default when installing nimble |
10:01:02 | PMunch | But I agree that the standard library could benefit from having more basic types as well. Makes it easier for libraries to re-use shared components |
10:43:38 | FromDiscord | <xoich (xoich)> what is awesomelib?↵(@voidwalker) |
10:44:10 | FromDiscord | <voidwalker> some "awesome X" kind of colletion of pacakges. Like the one maintained here : https://github.com/ringabout/awesome-nim |
10:44:29 | FromDiscord | <voidwalker> (edit) "colletion" => "collection" |
10:47:40 | FromDiscord | <luteva> is there an easy way of searching for projects that use a given lib/package? something like "nimble search dependency=some_lib"↵This could be great to get some real examples or for getting some ideas/inspiration of how to use that lib/package. |
10:48:19 | FromDiscord | <federico3> Shipping Nim without batteries included cripples its usability for real world production code |
10:48:39 | FromDiscord | <ShalokShalom> Why would that be the case |
10:48:46 | FromDiscord | <ShalokShalom> And why do you think it is the case |
10:48:54 | FromDiscord | <ShalokShalom> Cause they slim down the stdlib? |
10:54:40 | FromDiscord | <voidwalker> In reply to @luteva "is there an easy": search "import <pkgname>" language:nim on github |
10:55:44 | FromDiscord | <voidwalker> In reply to @federico3 "Shipping Nim without batteries": I agree, if anything, it should adopt great libs in the stdlib, not externalize them |
10:55:59 | FromDiscord | <federico3> Many organizations do supply chain management, they require build environments to be reproducible and the licenses to be vetted. This is much easier to implement if you have a good standard library or a bulkier development "kit" shipped in one archive rather than having to repackage a hundred tiny libraries. |
11:06:22 | FromDiscord | <Rika> In reply to @voidwalker "I agree, if anything,": Well are you willing to do the maintenance and work to make it so? |
11:07:56 | FromDiscord | <Rika> The reality is that the way the standard library is packaged increases the friction for maintaining such packages within, more than a separate package↵↵Of course there is the benefit of it being much more coherent but I believe there are better ways to have coherence without putting packages in the standard library graveyard |
11:08:02 | * | jmdaemon quit (Ping timeout: 246 seconds) |
11:08:33 | FromDiscord | <federico3> Yes I am.↵(@Rika) |
11:09:15 | FromDiscord | <Rika> Well that’s nice, I don’t have much to say about that other than I look forward to see the progress, seriously |
11:09:47 | FromDiscord | <arkanoid> Isn't this solved by using github hash in nimble file require ? |
11:10:02 | FromDiscord | <hdbg> What is wrong? https://media.discordapp.net/attachments/371759389889003532/1059428348285161502/image.png |
11:10:58 | FromDiscord | <federico3> No, unfortunately that's far from enough as it still needs to use nimble and pull stuff from the Internet to recreate a build environment |
11:11:37 | FromDiscord | <arkanoid> There's to learn from nix here |
11:12:00 | FromDiscord | <federico3> It's not my decision. There was a proposal to ship additional libraries as part of the release but it was rejected.↵(@Rika) |
11:12:23 | FromDiscord | <federico3> Not really. Distributions have been doing this for decades before Nix. |
11:12:30 | FromDiscord | <Rika> In reply to @federico3 "It's not my decision.": Why? |
11:35:58 | FromDiscord | <Entikan> how do I pre-compile modules so I don't have to constantly recompile them? |
11:36:32 | FromDiscord | <Entikan> preferably just in debug mode or something, so it compiles everything on release |
11:37:10 | FromDiscord | <Rika> Incremental compilation is not finished but you can experiment with it (I don’t know how exactly) |
11:38:08 | FromDiscord | <Entikan> --incremental:on breaks compilation, but nice to know that's what it is for |
11:41:17 | FromDiscord | <Entikan> sent a code paste, see https://play.nim-lang.org/#ix=4kac |
12:39:20 | NimEventer | New thread by sls1005: Nim book in Japanese, see https://forum.nim-lang.org/t/9790 |
12:48:56 | PMunch | Is there a way to get nimble to build two binaries from the same source on installation with different flags? |
13:17:36 | PMunch | Figured out a way which works, now NimLSP ships with a `nimlsp_debug` version so you won't have to build it yourself to be able to provide logs :) |
13:21:59 | FromDiscord | <Prestige> very nice |
13:27:54 | * | droidrage joined #nim |
13:41:07 | * | azimut quit (Quit: ZNC - https://znc.in) |
13:43:12 | * | azimut joined #nim |
14:00:28 | FromDiscord | <luteva> In reply to @voidwalker "search "import <pkgname>" language:nim": this doesn't seem to work. |
14:00:55 | FromDiscord | <voidwalker> @luteva click "Code" entry in the lefthand menu |
14:01:02 | FromDiscord | <voidwalker> https://github.com/search?q=%22import+binarylang%22+language%3ANim&type=code |
14:01:40 | FromDiscord | <luteva> ahh ok i tried the 'man' search |
14:02:22 | FromDiscord | <voidwalker> of course, this is for github only. There are a small number of projects only hosted on gitlab.. maybe gitlab has some similar functionality. |
14:03:05 | FromDiscord | <voidwalker> Anyone know if Araq reads (or receives in the first place) PMs on discord ? |
14:03:45 | FromDiscord | <ringabout> In reply to @voidwalker "Anyone know if Araq": Depends what's the topic |
14:03:53 | FromDiscord | <ringabout> (edit) "In reply to @voidwalker "Anyone know if Araq": Depends ... what's" added "on" |
14:04:06 | Amun-Ra | does sender know the message was read? |
14:04:17 | Amun-Ra | f.e. as in fb messenger? |
14:04:28 | FromDiscord | <voidwalker> I really want a PDF of his book. destroyed my book attempting to scan it, and the result is not satisfactory, slow page loads, OCR not perfect for code.. |
14:05:18 | FromDiscord | <voidwalker> I know most people that bought the book were unhappy with not getting a PDF as well, so maybe this issue can be addressed. |
14:06:10 | FromDiscord | <ringabout> In reply to @voidwalker "I really want a": You can email him. |
14:06:14 | FromDiscord | <voidwalker> This would make many happy. I know he expressed the view that the book should be read on paper, but that's obviously not what most of us want to do |
14:06:35 | FromDiscord | <voidwalker> I like to read literature on paper, not tables with ascii codes : P |
14:06:56 | FromDiscord | <ringabout> In reply to @ringabout "You can email him.": Here is th email https://github.com/Araq |
14:07:00 | FromDiscord | <ringabout> (edit) "th" => "the" |
14:07:16 | FromDiscord | <voidwalker> I already pm-ed here.. I will wait a few days for reply before e-mail, so not to spam. Thanks |
14:08:28 | FromDiscord | <ringabout> As far as I'm concerned, pming him in some channels may not work. |
14:08:42 | FromDiscord | <voidwalker> I pm-ed him, not in channel |
14:08:49 | FromDiscord | <voidwalker> DM |
14:24:17 | FromDiscord | <luteva> In reply to @voidwalker "<@954521401073754212> click "Code" entry": oh great that worked! Gonna stop programming right now, as what i am working on, does already exist 😄 |
14:24:49 | FromDiscord | <voidwalker> yeah, good thing to not repeat the same projects over and over if it can be helped. so many things missing |
14:26:02 | FromDiscord | <voidwalker> Also I noticed there are lots of projects started with enthusiasm, with great ideas, but never got anywhere close to being finished, abandoned. |
14:26:35 | FromDiscord | <voidwalker> Then somebody else decides to do that same project as well, and it also gets nowhere : D |
14:27:30 | FromDiscord | <ringabout> cs.github.com is convenient too. |
14:27:45 | FromDiscord | <ringabout> https://cs.github.com/?q=%22import+binarylang%22+language%3ANim |
14:39:10 | * | rockcavera joined #nim |
14:40:39 | * | qwestion joined #nim |
14:42:06 | FromDiscord | <Phil> In reply to @xoich (xoich) "I think nim-result is": Note that this may run into the issue that you can only specify 1 return type or you'll find yourself defining a bunch of tuples or object types to specify the permutation of result + possible exceptions for the return type |
14:43:59 | FromDiscord | <Phil> (edit) "In reply to @xoich (xoich) "I think nim-result is": Note that this may run into the issue that you can only specify 1 ... returnalongside" added "error type to" | "type" => "alongside your actual return.↵That" | removed "result +" | "the return type" => "a given proc" |
14:45:12 | FromDiscord | <Phil> I guess you can also return an Object variant containing either the actual result or the exceptions, but damn that's a lot of typing |
14:46:19 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4kaK |
14:47:02 | FromDiscord | <voidwalker> oh you mean it should be possible to return two errors at the same time, I understand now |
14:47:22 | FromDiscord | <Phil> Not even that, naturally you can also use enums but that loses you all previous information |
14:47:32 | FromDiscord | <Phil> (edit) "Not even that, naturally you can also use enums but that loses you all previous information ... " added "associated with the actual exception" |
14:48:04 | FromDiscord | <Phil> So if your caller decides that it's the right move to log that exception, well good luck |
14:48:07 | FromDiscord | <voidwalker> I did not consider this would be ever needed. I was just going through this lib as well contemplating how/if I could use it for my torrent project |
14:48:48 | FromDiscord | <Phil> In reply to @voidwalker "I did not consider": Accessing exception information is one of the first usecases I think of whenever Results come into play as often times I want to log them |
14:50:20 | FromDiscord | <⚶ Zeno> sent a code paste, see https://play.nim-lang.org/#ix=4kaM |
14:50:45 | FromDiscord | <Phil> That's why enums aren't truly an option in my opinion. I want that exception object. ↵And that you only get if you start playing around with the error-type being either an object, a tuple or you just return an object variant in the first place |
14:51:49 | FromDiscord | <Phil> In reply to @⚶ Zeno "hello people, how can": if the object itself is mutable, any of its fields are mutable.↵That is, assuming they're accessible.↵You can hide an object's field by not exporting them. If you want to make it readable but not writable to outside of its module, then just don't export the field, but provide a "getter" to the property |
14:52:20 | FromDiscord | <Bung> `var int` is invalid in this context |
14:52:55 | FromDiscord | <voidwalker> I guess the object fields inherit the mutability of the object variable |
14:53:16 | FromDiscord | <⚶ Zeno> In reply to @Isofruit "if the object itself": so how can i make object mutable ? |
14:53:25 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4kaO |
14:53:31 | FromDiscord | <Phil> In reply to @⚶ Zeno "so how can i": `var x = A()`↵X is mutable now |
14:53:34 | FromDiscord | <Phil> (edit) "A()`↵X" => "A()`↵x" |
14:53:41 | FromDiscord | <Bung> it's mutable depends how you use it |
14:54:05 | FromDiscord | <Phil> sent a code paste, see https://paste.rs/2dp |
14:54:58 | FromDiscord | <⚶ Zeno> hold on a second, i will upload images |
14:55:13 | FromDiscord | <⚶ Zeno> https://media.discordapp.net/attachments/371759389889003532/1059485016146595840/image.png |
14:55:24 | FromDiscord | <⚶ Zeno> (edit) "hold on a second, i will upload images ... " added "(2 of them)" |
14:55:27 | FromDiscord | <⚶ Zeno> https://media.discordapp.net/attachments/371759389889003532/1059485075667955732/image.png |
14:55:43 | FromDiscord | <Phil> sent a code paste, see https://paste.rs/WY9 |
14:55:53 | FromDiscord | <⚶ Zeno> yea thats what i want |
14:56:06 | FromDiscord | <Bung> so send(node: var Node) |
14:56:29 | FromDiscord | <⚶ Zeno> ooh i forgot about that |
14:56:54 | FromDiscord | <⚶ Zeno> yeah that fixes the error now, thanks ! |
14:57:05 | FromDiscord | <Phil> I highly recommend playing around with that.↵It should copy every reassignment with non-ref types, but I always need to write myself mini-examples to double-check the compilers behaviour there |
14:59:24 | FromDiscord | <Phil> Generally, I find its somewhat rough to figure out in nim when it copies and when it doesn't, haven't quite gotten a feel for that yet.↵Though I also fundamentally avoid mutation nowadays, particularly in my nim-code, so I guess that explains why I haven't developed a good feel for it yet. |
14:59:45 | FromDiscord | <⚶ Zeno> understandable |
15:06:49 | FromDiscord | <Require Support> getting this weird segfault with orc, everytime i run my program i get a different stack trace. I'm not using async or threading. Any idea how I can get to the root problem? running on windows |
15:07:40 | FromDiscord | <Require Support> without orc, it works fine |
15:09:08 | * | PMunch quit (Quit: Leaving) |
15:10:37 | FromDiscord | <luteva> sent a code paste, see https://paste.rs/YAW |
15:11:10 | FromDiscord | <luteva> (edit) "https://play.nim-lang.org/#ix=4kb0" => "https://paste.rs/5VL" |
15:11:47 | FromDiscord | <luteva> (edit) "https://play.nim-lang.org/#ix=4kb2" => "https://play.nim-lang.org/#ix=4kb1" |
15:26:12 | FromDiscord | <Phil> In reply to @luteva "is there an easy": This is an example of a pragma annotation.↵To read in pragmas, you want to to use "getCustomPragmaVal" and the like, that stuff should be in....errrr let me check... |
15:26:50 | FromDiscord | <Phil> std/typetraits |
15:30:08 | FromDiscord | <Phil> sent a long message, see http://ix.io/4kb9 |
15:30:42 | FromDiscord | <Phil> Nimibook docs from snorlogue about that pragma thingy:↵https://philippmdoerner.github.io/Snorlogue/bookCompiled/fileFields.html |
15:34:25 | * | arkurious joined #nim |
15:40:16 | FromDiscord | <luteva> @Phil so, in that case:↵hasCustomPragma(dummyValue, subdir)↵the subdir is the pragma and the dummyvalue is the directory, right? Or what is the "dummyvalue"? |
15:41:52 | FromDiscord | <ambient> sent a code paste, see https://play.nim-lang.org/#ix=4kbg |
15:41:59 | FromDiscord | <ambient> (I do not want every tuple (int, int) be Coord2D) |
15:42:59 | FromDiscord | <Phil> In reply to @luteva "<@180601887916163073> so, in that": That is the field that is annotated with the subdir pragma.↵Keep in mind in that code I am iterating over the fields of the type in an unrolled for-loop, so after the compiler is done with this, the code that stands there more correctly is `hascustomPragma(T()[].someField, subdir)` |
15:43:38 | FromDiscord | <Phil> with "someField" being whatever specific field fulfilled the conditions to get down to this specific piece of code |
15:44:23 | FromDiscord | <Phil> So could also be expressed as `hasCustomPragma(compileTimeInstance.myField, <pragma-name>)` |
15:44:49 | FromDiscord | <luteva> not an _easy_ (but complete) example.... 😜 |
15:45:21 | FromDiscord | <luteva> but nevermind i'm gonna get it... 🙂 |
15:45:27 | FromDiscord | <Phil> Okay fair, but I'm at work and that was the fastest I could do without being able to quickly compile nim code |
15:45:35 | FromDiscord | <Phil> ^^ |
15:46:20 | FromDiscord | <Phil> Yeah, hopefully that gives you a bit of a better idea.↵Generally this kind of stuff all acts at compile-time and I see it mostly used when doing meta-programming that involves iterating over all fields on a type |
15:46:36 | FromDiscord | <ambient> sent a code paste, see https://play.nim-lang.org/#ix=4kbi |
15:47:02 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4kbj |
15:48:06 | FromDiscord | <Phil> They are there to make writing code easier because writing `type ActionProc = proc(x: int, y: string, z: float): 0..2` and then using ActionProc everywhere is easier on the eyes than actually writing the proc definition everywhere |
15:48:26 | FromDiscord | <Phil> For making stuff explicitly different you got distinct |
15:50:56 | FromDiscord | <ambient> sent a code paste, see https://paste.rs/yUi |
15:51:04 | FromDiscord | <ambient> seq[(int, int)] |
15:51:25 | FromDiscord | <voidwalker> sent a code paste, see https://paste.rs/gUE |
15:51:37 | FromDiscord | <voidwalker> `'params' is of type <openArray[(string, string)]> which cannot be captured as it would violate memory safety,` |
15:52:45 | FromDiscord | <Phil> In reply to @ambient "It just causes this": I'd need to see the code there |
15:53:18 | FromDiscord | <ambient> sent a code paste, see https://play.nim-lang.org/#ix=4kbm |
15:53:55 | FromDiscord | <ambient> The error is in the part 1 line |
15:57:47 | FromDiscord | <Phil> Alrighty, off work so lets dive into this |
15:58:23 | FromDiscord | <Phil> How exactly do you get the aoc thingy? |
15:58:32 | FromDiscord | <Phil> I know its advent of code, I just never did advent of code |
15:58:35 | FromDiscord | <ambient> In reply to @Isofruit "I know its advent": https://github.com/amb/aoc2022/blob/master/aoc_logic.nim |
16:00:18 | FromDiscord | <voidwalker> that guy really likes aoc |
16:00:32 | FromDiscord | <ambient> It's a pretty fun way to learn a language |
16:03:02 | FromDiscord | <Phil> I don't get this repo |
16:03:17 | FromDiscord | <Phil> So what, I copy the aoc file, include it and that's it? |
16:03:22 | FromDiscord | <Phil> How do you know what your lines are? |
16:03:30 | FromDiscord | <ambient> aoc & aoc_logic |
16:04:16 | FromDiscord | <ambient> lines is in the day template |
16:04:44 | FromDiscord | <Phil> So I need to install the entire repo, not just copy-paste the files? |
16:05:22 | FromDiscord | <Phil> Wait, those are solutions, ugh |
16:05:25 | FromDiscord | <ambient> well I didn't expect that to be required, it's WIP |
16:06:44 | FromDiscord | <Phil> Could you give me the lines without the entire aoc stuff surrounding it so I can have a nicer minimal example? |
16:06:56 | FromDiscord | <Phil> Basically just defines the "lines" variable with an example input |
16:07:02 | FromDiscord | <ambient> I'll try and see if I can just write a simple test case |
16:12:24 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4kbr |
16:12:53 | FromDiscord | <Phil> Just added casting the `char` types to `int` in order to do math as there are no `-` operators defined for cha, that's pretty much it |
16:13:40 | FromDiscord | <ambient> Yeah a simpler program works fine, I don't know what exactly is going wrong. Might be something to do with the templates |
16:14:19 | FromDiscord | <ambient> https://play.nim-lang.org/#ix=4kbt |
16:14:45 | FromDiscord | <Phil> In that case I'm out, given my lack of knowledge of aoc this seems more of a custom code kind of issue |
16:15:18 | FromDiscord | <ambient> well the templates are quite straight forward and just exist as an attempt to make the code cleaner and the ability to batch run the days |
16:19:37 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4kbv |
16:20:14 | FromDiscord | <Bung> echo @params.len |
16:25:22 | FromDiscord | <voidwalker> that didn't do it @Bung `proc `@`[T](a: openArray[T]): seq[T]` |
16:26:28 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4kby |
16:27:23 | FromDiscord | <Bung> no idea, I never discard async proc |
16:28:22 | FromDiscord | <voidwalker> I just put it there to reproduce the code context I had the error in the first plac |
16:28:27 | FromDiscord | <voidwalker> (edit) "plac" => "place" |
16:30:03 | FromDiscord | <voidwalker> oh wait righg, that's a bad example for async indeed.. wait |
16:30:08 | FromDiscord | <voidwalker> (edit) "righg," => "right," |
16:30:49 | FromDiscord | <ambient> sent a code paste, see https://play.nim-lang.org/#ix= |
16:31:07 | FromDiscord | <voidwalker> sent a code paste, see https://paste.rs/UWL |
16:32:23 | FromDiscord | <ambient> -d:nimNoLentIterators solves my issue, but I'm still unsure what is exactly the cause |
16:32:33 | FromDiscord | <voidwalker> well, it is async related, no async and it compiles |
16:35:42 | FromDiscord | <Bung> oh , I see "Procedures marked {.async.} do not support mutable parameters such↵## as `var int`. References such as `ref int` should be used instead." |
16:36:37 | FromDiscord | <voidwalker> but what is var here ? |
16:36:55 | FromDiscord | <Bung> hidden pointer |
16:38:07 | FromDiscord | <voidwalker> right, so I have to give up on openArray or is there a workaround ? |
16:38:23 | FromDiscord | <voidwalker> I don't really need openArray, but now I am curious to understand what is going on |
16:39:18 | FromDiscord | <Bung> so use generic with seq[string]| tuple[string,string] |
16:39:27 | FromDiscord | <Bung> (edit) "seq[string]|" => "seq[string] |" |
16:40:57 | FromDiscord | <voidwalker> haha ok, as I don't really need it, I will stick with seq : P |
16:41:04 | FromDiscord | <Bung> (edit) "so use generic with seq[string] | tuple[string,string] ... " added "for example, I dont know what types you wanna input" |
16:41:39 | FromDiscord | <voidwalker> actually I might need it... |
16:42:00 | FromDiscord | <voidwalker> I want array[n, (string, string)] or seq[(string, string)].. thus the openArray |
16:43:14 | FromDiscord | <Crews> Hello! I'm an F# developer looking to do more systems-level programming. F# has Algebraic Data Types, which include Unions/Discriminated Unions.↵↵Are there good examples of how Nim solves the problem of having a type that could be one of several types? |
16:46:21 | FromDiscord | <Bung> generic and typeclass |
16:46:35 | FromDiscord | <Rika> Nim has a more funky working kind of discriminated union |
16:52:45 | FromDiscord | <Crews> In reply to @Rika "Nim has a more": Could you elaborate? |
16:54:40 | FromDiscord | <Rika> Better to just see this https://nim-lang.org/docs/manual.html#types-object-variants |
16:58:13 | FromDiscord | <voidwalker> aren't concepts better suited for this kind of modeling / |
16:58:26 | FromDiscord | <voidwalker> I don't know much about it, but found this post: https://github.com/nim-lang/RFCs/issues/5#issuecomment-649596198 |
16:58:28 | FromDiscord | <Rika> Depends |
16:59:24 | FromDiscord | <Rika> Concepts of course still don’t allow for heterogeneous containers |
17:00:08 | FromDiscord | <Rika> Of course object variants only emulate it but concepts wouldn’t help at all I think |
17:04:28 | FromDiscord | <jtv> Your concrete type w concepts can be a discriminated union and you can effectively do the type casing at compile time |
17:04:43 | FromDiscord | <Crews> sent a code paste, see https://play.nim-lang.org/#ix=4kbH |
17:05:00 | FromDiscord | <Crews> In reply to @jtv "Your concrete type w": Do you have a link to an example of that? |
17:08:01 | * | nmz joined #nim |
17:16:42 | FromDiscord | <ShalokShalom> @Crews There are macros, who let it look like DUs↵↵Fellow FSharper here |
17:17:16 | FromDiscord | <ShalokShalom> https://github.com/andreaferretti/patty#constructing-variant-objects |
17:17:25 | FromDiscord | <ShalokShalom> Thats a pattern matching library |
17:17:34 | FromDiscord | <ShalokShalom> That also supports DUs. |
17:18:08 | FromDiscord | <Crews> In reply to @ShalokShalom "<@822242039437066280> There are macros,": Yeah, I love F#, but I've been pushing the performance and Nim seems like a nice next step. I'd rather not work in raw C 🤣 |
17:18:51 | FromDiscord | <ShalokShalom> F# and Nim are surprisingly similar |
17:19:50 | * | pro joined #nim |
17:19:58 | FromDiscord | <ShalokShalom> https://github.com/ringabout/awesome-nim#functional-programming |
17:20:02 | FromDiscord | <Crews> In reply to @ShalokShalom "F# and Nim are": Yes! They feel like cousin languages even though F# comes from the ML family and Nim is apparently from more of the Python line |
17:20:22 | FromDiscord | <ShalokShalom> Nim often does not know, that it's functional, when it is. ↵↵Take this list, as an example. |
17:20:45 | FromDiscord | <ShalokShalom> In reply to @Crews "Yes! They feel like": Nim is actually an Oberon/Pascal like language |
17:21:06 | FromDiscord | <Crews> In reply to @ShalokShalom "Nim is actually an": Don't know Oberon. Have to look it up... |
17:21:08 | FromDiscord | <ShalokShalom> It's syntax just looks like Python and there are many useful Python related libraries |
17:21:26 | FromDiscord | <ShalokShalom> Like Nimpy, that lets you use Python libraries |
17:22:01 | FromDiscord | <wiga> Any way to compress data with staticRead and compress it on compile time? |
17:23:05 | FromDiscord | <wiga> I have tried using zippy gzip compression but doesn't work on compile time |
17:43:16 | FromDiscord | <luteva> how can i get all types of a module? |
17:46:38 | FromDiscord | <luteva> sent a code paste, see https://play.nim-lang.org/#ix=4kbX |
17:49:25 | FromDiscord | <luteva> sent a long message, see http://ix.io/4kbY |
17:54:38 | FromDiscord | <luteva> or do i totally misunderstand how this should be used? |
17:57:13 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/r6C |
18:00:05 | FromDiscord | <luteva> ok this is by using a concept..... so this is probably the easiest way?!?↵Would it be possible to get all types of a module and check if the type uses the pragma? (just for learning) |
18:00:22 | FromDiscord | <Elegantbeef> Nope |
18:00:28 | FromDiscord | <luteva> ok thx. |
18:00:33 | FromDiscord | <Elegantbeef> You cannot query a module for symbols without hacks |
18:00:40 | FromDiscord | <luteva> ok |
18:10:38 | FromDiscord | <Entikan> Anyone have an idea how I can pre-compile a set of nim modules to be imported by another nim project? |
18:10:49 | FromDiscord | <Entikan> would save me a lot of compile time |
18:11:09 | FromDiscord | <Entikan> --incremental:on doesn't seem to work for me, probably because it is at an experimental state. |
18:12:44 | FromDiscord | <Entikan> I'm not experienced enough with nim to narrow down my problem with --incremental |
18:13:41 | FromDiscord | <Entikan> I want to use a pretty big set of bindings but it's taking so long to compile now |
18:16:50 | FromDiscord | <Elegantbeef> There isnt much of a way to do that as of yet |
18:19:44 | FromDiscord | <⚶ Zeno> how can i solve "of type <var ....> which cannot be captured as it would violate memory safety" errors ? |
18:19:55 | FromDiscord | <Elegantbeef> Depends |
18:19:59 | FromDiscord | <Elegantbeef> You can copy the variable |
18:20:09 | FromDiscord | <⚶ Zeno> i do need the original variable itself though |
18:20:09 | FromDiscord | <Elegantbeef> Or pass in a reference without `var` |
18:20:12 | FromDiscord | <emanresu3> Hi, any recommendations for an xml parser and web requests? are the one in standard library good enough (httpclient, parsexml)? |
18:20:17 | FromDiscord | <⚶ Zeno> im reassigning attributes of it |
18:20:30 | FromDiscord | <⚶ Zeno> https://media.discordapp.net/attachments/371759389889003532/1059536681042198608/image.png |
18:20:32 | FromDiscord | <Elegantbeef> Well then change the object to a reference |
18:20:36 | FromDiscord | <Elegantbeef> and pass it in without var |
18:20:40 | FromDiscord | <⚶ Zeno> alright, thanks |
18:21:27 | FromDiscord | <Elegantbeef> Technically if you know it's safe to you can copy the address to a local variable and access that, but that's unsafe nim |
18:24:19 | FromDiscord | <⚶ Zeno> In reply to @Elegantbeef "and pass it in": well im dumb, can you give quick example ? |
18:24:49 | FromDiscord | <⚶ Zeno> sent a code paste, see https://play.nim-lang.org/#ix=4kc5 |
18:25:03 | FromDiscord | <⚶ Zeno> and when you say "pass it in without var", i understand it as just keep type of parameters as "Node" |
18:25:10 | FromDiscord | <⚶ Zeno> and now i get this https://media.discordapp.net/attachments/371759389889003532/1059537854549733416/image.png |
18:25:38 | FromDiscord | <⚶ Zeno> (ask if you want full error, but i think thats enough picture ?) |
18:25:49 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4kc6 |
18:25:58 | FromDiscord | <⚶ Zeno> (edit) "https://play.nim-lang.org/#ix=4kc5" => "https://play.nim-lang.org/#ix=4kc7" |
18:26:01 | FromDiscord | <Elegantbeef> The issue is now with `ref` you need to explicitly allocate either doing `new MyObject` or `MyObject(...)` |
18:26:10 | FromDiscord | <Elegantbeef> It's a heap allocated type now |
18:27:23 | FromDiscord | <Require Support> stack traces when using libraries with orc 💀 you never know what is going wrong |
18:27:58 | FromDiscord | <⚶ Zeno> In reply to @Elegantbeef "The issue is now": oh that is fine |
18:28:05 | FromDiscord | <⚶ Zeno> anyway thanks a lot, now it works |
18:28:15 | FromDiscord | <⚶ Zeno> i just didnt know i had to do `new ...` or `...()` |
18:28:52 | FromDiscord | <⚶ Zeno> (edit) "In reply to @Elegantbeef "The issue is now": oh that is fine ... " added "(for me)" |
18:29:10 | FromDiscord | <Elegantbeef> The issue with var and closures is that the variable could be on the stack which means you can have a dangling pointer |
18:29:17 | FromDiscord | <Crews> What editor/IDE do people recommend for Nim development? |
18:29:20 | FromDiscord | <Elegantbeef> Just to explain why |
18:29:24 | FromDiscord | <⚶ Zeno> i see |
18:29:46 | * | wallabra joined #nim |
18:29:46 | FromDiscord | <⚶ Zeno> In reply to @Crews "What editor/IDE do people": thats personal opinion, but for my case i use nim, i also saw ppl use neovim |
18:29:49 | FromDiscord | <⚶ Zeno> use whatever ur comfortable with |
18:29:58 | FromDiscord | <⚶ Zeno> (edit) "nim," => "VSC," |
18:30:20 | FromDiscord | <Crews> In reply to @⚶ Zeno "thats personal opinion, but": Extension you recommend? I see a couple |
18:30:51 | FromDiscord | <⚶ Zeno> nimsaem:Nim↵and code runner if ur too lazy to do `nim c -r ...` repeatedly |
18:32:54 | FromDiscord | <ShalokShalom> In reply to @Crews "Extension you recommend? I": If it does make issues to you:↵↵https://discord.com/channels/371759389889003530/371759389889003532/1054117863125958716 |
18:33:16 | FromDiscord | <ShalokShalom> There is also a Jetbrains implementation |
18:33:26 | FromDiscord | <ShalokShalom> That's different, implementation wise |
18:33:54 | FromDiscord | <Elegantbeef> There's an LSP and it's all backed by nimsuggest so the experience is pretty much the same everywhere |
18:33:54 | FromDiscord | <Elegantbeef> I personally use kate + nimlsp |
18:34:00 | FromDiscord | <ShalokShalom> Otherwise, all besides the IntelliJ one depend on the compiler-own "nimsuggest" |
18:34:33 | FromDiscord | <Crews> I have the JetBrains suite so I guess I'll try that as well |
18:34:53 | FromDiscord | <Elegantbeef> The jetbrains extension is much simpler than nimsuggest |
18:35:34 | FromDiscord | <Elegantbeef> It doesnt compile the code so templates/macros that add symbols will not be visible |
18:45:07 | * | pro quit (Quit: pro) |
18:45:33 | FromDiscord | <jtv> @Crews Sorry I went into a lunch, did you figure out how to do what you want to do? |
19:09:10 | FromDiscord | <4zv4l> I have a question about a nim program, I would understand if it's not appropriate to answer or send the code↵basically last year I had to make a ransomware in C using openssl aes encryption↵I tried making one in Nim which I thought were working (on an filesystem I made myself) but my colleague sent me the teacher's test filesystem and when I decrypted I didn't get the same checksum (sha256)↵can I share the code to get why ? |
19:12:38 | FromDiscord | <voidwalker> Are you kidnapped and force to code ransomware? |
19:12:46 | FromDiscord | <voidwalker> (edit) "force" => "forced" |
19:13:06 | FromDiscord | <voidwalker> (edit) "Are you kidnapped and forced to code ransomware? ... " added "Or what do you mean by "I had to"" |
19:13:32 | FromDiscord | <voidwalker> Or had to like a school assignment |
19:13:35 | FromDiscord | <4zv4l> lmao I am not↵I just wanna understand why the decryption sometimes works and sometimes does not↵↵oh "had to" because last year I had to, to get my grade |
19:13:40 | FromDiscord | <4zv4l> that was our exam |
19:14:25 | FromDiscord | <voidwalker> So you want your homework done, ok |
19:14:30 | FromDiscord | <4zv4l> ||https://github.com/4zv4l/ransomware|| |
19:14:31 | FromDiscord | <4zv4l> no no |
19:14:34 | FromDiscord | <4zv4l> I made it already last year |
19:14:38 | FromDiscord | <4zv4l> now I am making it in Nim |
19:14:40 | FromDiscord | <4zv4l> to try |
19:15:19 | FromDiscord | <4zv4l> and I thought it was working until my mate sent me a folder containing random files↵and when I the content wasn't the same as before |
19:15:21 | * | derpydoo joined #nim |
19:15:27 | FromDiscord | <4zv4l> just wanna know why↵if I can ask |
19:16:18 | FromDiscord | <voidwalker> well that's a completely meaningless question without code context |
19:16:53 | FromDiscord | <4zv4l> that's why I asked if I can send it xD |
19:16:56 | FromDiscord | <voidwalker> you seem experienced enough to debug it to a point where you can see what bytes get hashed, to know why it fails |
19:17:42 | FromDiscord | <4zv4l> well I use a lib `nimAES` which seems a bit weird to use with aes CTR |
19:18:05 | FromDiscord | <jtv> Still, if two checksums aren't the same, then the two inputs aren't the same. |
19:18:35 | FromDiscord | <jtv> So do the work to figure out where the inputs are different and why, and if there's something that doesn't make sense about it, then perhaps we can help |
19:19:01 | FromDiscord | <4zv4l> well the `why` is why I am here |
19:19:16 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kcm |
19:19:27 | FromDiscord | <jtv> "weird to use with CTR" is surprising. If it has a raw AES encrypt of an openarray[16, byte] it should be easy to implement counter mode yourself |
19:19:36 | FromDiscord | <4zv4l> it works just fine with hand made files |
19:19:48 | FromDiscord | <4zv4l> but I guess there are exception which is what I try to understand |
19:21:38 | FromDiscord | <jtv> Why are you using AES-CTR instead of something like AES-GCM, which will at least help you detect when the ciphertext is invalid for some reason?? |
19:24:14 | FromDiscord | <jtv> But nothing above is going to make it easy for us to help you... there's not enough context for us. Like @voidwalker said, you should be able to figure out where the problem is a lot more specifically, i.e., where exactly you end up w/ 2 strings that don't match. And at that point, you'll hopefully be able to generate a much more specific question, because otherwise it's not much better than "please debug my code". |
19:26:04 | FromDiscord | <4zv4l> In reply to @jtv "Why are you using": because there isn't in Nim AES I think |
19:26:04 | FromDiscord | <4zv4l> https://github.com/jangko/nimAES |
19:26:19 | FromDiscord | <4zv4l> I saw it's using stream so easier to use |
19:26:31 | FromDiscord | <jtv> Then I'd use a different library, because that's just rubbish |
19:26:33 | FromDiscord | <4zv4l> "easier" in the way that I can just pass it the content of the file |
19:26:53 | FromDiscord | <4zv4l> In reply to @jtv "Then I'd use a": do you have a good one ? |
19:26:57 | FromDiscord | <jtv> Same thing w/ any good GCM implementation. GCM is just CTR-mode for encryption, but a fast integrity check as part of it |
19:27:19 | FromDiscord | <jtv> Well, it's the default cipher suite for TLS, so I'm sure it's already buried in Nim's wrapping of OpenSSL |
19:28:09 | FromDiscord | <jtv> But anything that is going to give you a bunch of modes no cryptographer would use on its own anymore (or at all in the case of things like OFB, CFB, etc) is a toy project at best. |
19:28:34 | FromDiscord | <jtv> That library looks like it was built by someone who was excited to read Applied Cryptography, even though it's about 30 years old. |
19:29:57 | FromDiscord | <jtv> A quick search turns up nimcrypto, which I know gets used in a number of projects, and here's their GCM example: https://github.com/cheatfate/nimcrypto/blob/master/examples/gcm.nim |
19:31:16 | FromDiscord | <jtv> I have no clue if that would be leveraging underlying hardware support for GCM though, whereas OpenSSL definitely would, but is probably vastly underdocumented (openssl is complex, and the nim wrapping isn't well documented) |
19:31:48 | FromDiscord | <federico3> or you can use libsodium instead |
19:33:47 | FromDiscord | <jtv> Sure, that works too, though I was an author of GCM, so I'm contractually obliged to push it 😉 |
19:34:50 | FromDiscord | <4zv4l> yeah I'm taking a look a nimcrypto ^^↵thanks ! |
19:35:08 | * | jmdaemon joined #nim |
19:35:16 | FromDiscord | <jtv> I suspect if you make that switch your problem might go away, and if not, you should be able to pin down where it's failing more easil |
19:35:22 | FromDiscord | <jtv> At which point we can be more helpful |
19:47:15 | FromDiscord | <4zv4l> seems to work for now↵gonna try with the filesystem that made my previous code not working that well https://media.discordapp.net/attachments/371759389889003532/1059558507558469843/image.png |
19:52:25 | FromDiscord | <jtv> Cool |
19:55:00 | FromDiscord | <4zv4l> https://media.discordapp.net/attachments/371759389889003532/1059560463886725170/image.png |
19:55:04 | FromDiscord | <4zv4l> well so yeah↵some files are ok |
19:55:07 | FromDiscord | <4zv4l> some are not |
19:56:06 | FromDiscord | <4zv4l> sent a long message, see http://ix.io/4kcz |
19:56:07 | FromDiscord | <4zv4l> 3 files changed |
19:56:38 | FromDiscord | <jtv> Yeah, so you need to figure out where the input strings that you're passing in are differing. |
19:57:20 | FromDiscord | <jtv> GCM should be telling you whether decryption fails or not too. If the library has a mode where you can ignore that, it's not to spec, definitely make sure to test that |
19:57:38 | FromDiscord | <jtv> Because it shouldn't be the case that you COULD decrypt it without getting back what was put in |
20:01:36 | FromDiscord | <Entikan> In reply to @Elegantbeef "There isnt much of": well that sucks |
20:02:14 | FromDiscord | <Entikan> so much for efficiency |
20:02:30 | FromDiscord | <Entikan> I thought that was top priority |
20:03:29 | FromDiscord | <jtv> They're working on incremental compilation, but the "efficiency" is in compile time, not run time, so I'm surprised that's why you'd have issue w/ it? |
20:04:16 | FromDiscord | <Entikan> yeah me too to be honest |
20:05:53 | FromDiscord | <Entikan> the complexity is coming from these bindings: https://github.com/rdb/nim-panda3d |
20:05:59 | FromDiscord | <Entikan> perhaps it's doing something? |
20:06:39 | FromDiscord | <Entikan> it it because core.nim is one huge file |
20:07:23 | FromDiscord | <Entikan> (edit) "it" => "is" | "core.nim" => "panda3d/core.nim" | "file" => "file?" |
20:11:09 | FromDiscord | <jtv> I mean, if you're worried about compile time, without incremental compilation, breaking it up into smaller files isn't going to speed things up |
20:11:26 | FromDiscord | <jtv> You can generate a so and dynamically load it if you want?? |
20:12:02 | FromDiscord | <Entikan> that sounds nice. Can I just import so as if any nim module? |
20:13:32 | FromDiscord | <Entikan> In reply to @jtv "I mean, if you're": Yeah I figured. But Very Large Files is also something a lot of software seem to have quirks with. |
20:13:54 | FromDiscord | <Entikan> (edit) "In reply to @jtv "I mean, if you're": Yeah I figured. But ... Very" added "dealing with" |
20:16:23 | FromDiscord | <jtv> No, I would expect you have to call their wrapped dlopen(), and I don't know the flag magic to output a so yet, either. |
20:16:34 | FromDiscord | <jtv> But I've seen the wrapped dlopen() when looking through source |
20:17:46 | FromDiscord | <jtv> And while I assume there's a flag for .so output, it's definitely doable since you can target C output, then just control the link line yourself. |
20:18:29 | FromDiscord | <Elegantbeef> `--app:lib` |
20:18:35 | FromDiscord | <Entikan> I've made an so on accident with --app:lib |
20:18:36 | FromDiscord | <Entikan> yeah |
20:18:50 | FromDiscord | <Entikan> not sure what dlopen() is though (I come from python) |
20:19:11 | FromDiscord | <Elegantbeef> It's how one opens a dynamic linked library |
20:19:38 | FromDiscord | <Elegantbeef> The panda bindings iirc are needlessly complex |
20:19:54 | FromDiscord | <Entikan> In reply to @Elegantbeef "The panda bindings iirc": how so? |
20:20:10 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1059566796870529124/image.png |
20:20:15 | FromDiscord | <Entikan> note panda3d != pandas |
20:20:46 | FromDiscord | <Entikan> ah |
20:20:47 | FromDiscord | <jtv> The dlopen() interface is pretty straightforward though; man dlopen will give you the C version nim wraps |
20:21:04 | FromDiscord | <Entikan> I'll look into dlopen(), thanks! |
20:21:10 | FromDiscord | <Elegantbeef> They also have `init` procedures for 0'd types |
20:21:11 | FromDiscord | <Elegantbeef> Nim automatically zeros |
20:21:42 | FromDiscord | <Entikan> oh interesting |
20:22:08 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1059567289478942830/image.png |
20:22:11 | FromDiscord | <Elegantbeef> These could also just be a generic |
20:22:13 | FromDiscord | <Entikan> @ElegantBeef I don't suppose you could file a few issues about this >.< |
20:22:27 | FromDiscord | <Entikan> you'd be doing me a pretty huge favor |
20:23:20 | FromDiscord | <Elegantbeef> I think the author was already here and i mentioned using a dotoperator macro for the swizzling |
20:24:25 | FromDiscord | <Entikan> oh cool |
20:24:39 | FromDiscord | <4zv4l> sent a code paste, see https://paste.rs/kTm |
20:26:55 | FromDiscord | <4zv4l> all the checksum are wrong now |
20:27:15 | FromDiscord | <4zv4l> oh wait |
20:27:19 | FromDiscord | <4zv4l> no, same files as before |
20:27:29 | * | krux02_ joined #nim |
20:28:14 | FromDiscord | <jtv> The AAD is irrelevant, you can 100% skip it. |
20:28:46 | FromDiscord | <jtv> And the decryption definitely fails and does nothing if you change a random byte? |
20:28:51 | FromDiscord | <4zv4l> In reply to @jtv "The AAD is irrelevant,": did I skip it the right way ? |
20:29:27 | FromDiscord | <jtv> You don't need to provide it. It's just assumed to be an empty string if it doesn't exist. I guess the API could require it but I'd doubt it |
20:29:29 | FromDiscord | <4zv4l> In reply to @jtv "And the decryption definitely": what do you mean ? some files succeeded to be decrypted |
20:29:38 | FromDiscord | <4zv4l> In reply to @jtv "You don't need to": it requires it |
20:30:29 | FromDiscord | <jtv> Weird, that API makes you rekey every time you want toc change the nonce?? |
20:30:57 | FromDiscord | <jtv> I'd assume there's some sort of rekey function |
20:31:44 | FromDiscord | <jtv> Honestly, if I were designing it, I'd probably just use a hash of the file name truncated to 12 bytes as the nonce (12 bytes is a special maximally efficient size for GCM) |
20:32:15 | FromDiscord | <jtv> But each file should get its own nonce. |
20:32:22 | FromDiscord | <jtv> Still, I don't think that's likely to be your problem |
20:32:44 | FromDiscord | <4zv4l> yeah I really don't see why it works on some files and on some others doesn't |
20:34:30 | FromDiscord | <jtv> So the length of the ciphertext is 16 bytes LONGER than the plaintext |
20:34:42 | FromDiscord | <jtv> Because of the integrity check |
20:35:40 | FromDiscord | <Elegantbeef> @Entikan\: there you go i made an issue, you can either implement the changes or await the maintainer 😛 |
20:35:48 | FromDiscord | <jtv> So could be some low-level issue where you're essentially potentially getting some extra bytes in the output that should not be there, IDK |
20:36:14 | FromDiscord | <jtv> Spot check doesn't show any other big reasons. If this were C, the most likely culprit would be the file being opened in text mode |
20:36:51 | FromDiscord | <jtv> But I'm pretty sure Nim always does binary with the standard file APIs |
20:38:14 | FromDiscord | <4zv4l> In reply to @jtv "So the length of": I tried adding the size change but then no file was decrypted correctly |
20:40:53 | FromDiscord | <Entikan> In reply to @Elegantbeef "<@716041936758374501>\: there you go": thank you so much!!! <3<3<3 |
20:41:21 | FromDiscord | <jtv> Well, when you don't do that, do the files get written to the correct length? The output file will be 16 bytes longer than the input file |
20:42:03 | FromDiscord | <jtv> And when decryption fails, would be nice to know whether the sizes are the same, and whether the contents LOOK decrypted |
20:46:37 | FromDiscord | <<She>Horizon</Her>> What does the inline pragma do in Nim? |
20:46:56 | FromDiscord | <4zv4l> https://media.discordapp.net/attachments/371759389889003532/1059573529143672892/image.png |
20:46:59 | FromDiscord | <4zv4l> yeah it keeps the same size |
20:47:23 | FromDiscord | <4zv4l> but the content afterwards is not good good |
20:49:12 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kcY |
20:50:19 | FromDiscord | <jtv> Well I can promise you GCM's correct output is 16 bytes longer than the input |
20:50:43 | FromDiscord | <jtv> So they're probably doing the dumb thing where they separate the authentication information which is explicitly NOT allowed in the spec |
20:51:12 | FromDiscord | <voidwalker> So the teachers are buggy ? |
20:51:57 | FromDiscord | <jtv> Oh yeah, it's there in their code, they separate out the last 16 bytes into a "tag" field, which is again a horrible idea |
20:52:25 | FromDiscord | <jtv> There 100% should be an API call to check the tag before returning any decrypted value |
20:52:51 | FromDiscord | <jtv> By spec, those 16 bytes are supposed to be the last 16 bytes of the ciphertext |
20:54:17 | FromDiscord | <jtv> But even so, you're still at the point where SOMETHING is different, and you should inspect the actual contents to see which bytes are decrypting and which ones aren't |
20:56:11 | FromDiscord | <4zv4l> like this ? |
20:56:13 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kd0 |
20:56:21 | FromDiscord | <4zv4l> (edit) "https://paste.rs/Vsz" => "https://play.nim-lang.org/#ix=4kd1" |
20:57:40 | FromDiscord | <jtv> Yeah, so that tells me you aren't passing the same state off. |
20:57:45 | FromDiscord | <jtv> Here's what I think is happening |
20:59:44 | FromDiscord | <jtv> sent a long message, see http://ix.io/4kd2 |
20:59:47 | FromDiscord | <jtv> Or something along those lines. |
21:00:37 | FromDiscord | <4zv4l> I should create a new context for each file ? |
21:00:40 | FromDiscord | <jtv> Giving each file a unique nonce allows you to also decrypt one file at a time |
21:00:43 | FromDiscord | <4zv4l> would that be a solution ? |
21:01:05 | FromDiscord | <jtv> Well, like I said, the library should absolutely give you a way to change the nonce and AAD WITHOUT having to rekey AES (which is relatively expensive) |
21:02:07 | FromDiscord | <jtv> So for each file, I'd set up a new nonce, and the nonce would be the SHA-256 of a string consisting of a file name concatenated with the file length, truncating the SHA-256 output to 12 bytes. |
21:05:11 | FromDiscord | <4zv4l> oh |
21:05:12 | FromDiscord | <4zv4l> it works |
21:05:28 | FromDiscord | <4zv4l> that was indeed the renew of the nonce which made the order of the files important |
21:06:33 | FromDiscord | <jtv> Good to hear |
21:06:42 | * | derpydoo quit (Ping timeout: 252 seconds) |
21:07:15 | FromDiscord | <jtv> The way your code was before, the problem was NOT renewing the nonce, and having the file order change due to the hash order changing 🙂 |
21:07:29 | FromDiscord | <jtv> Glad we got it sorted, though |
21:08:44 | FromDiscord | <4zv4l> In reply to @jtv "So for each file,": I'll try doing this now |
21:12:18 | FromDiscord | <jtv> Some of the ransomware I've seen will use a separate key for each file, then allowing the ransomware team give the victim a taste... here, we'll give you a program to unencrypt this one file, but without having to give them what they need to unencrypt everything, unless they pay. |
21:13:19 | FromDiscord | <4zv4l> well my purpose is really not to arm anyone↵I just wanted to succeed making this work in Nim |
21:13:25 | FromDiscord | <4zv4l> and finally |
21:13:26 | FromDiscord | <4zv4l> it does |
21:14:01 | FromDiscord | <jtv> Yeah, sure, but anyone who wants to build this stuff for offensive purposes isn't going to have a hard time already. hash the file name and length, then use THAT key to do the |
21:14:04 | FromDiscord | <4zv4l> In reply to @jtv "Some of the ransomware": so they need to keep track of which key has been used for which file ? |
21:14:10 | FromDiscord | <jtv> Nope |
21:14:18 | FromDiscord | <jtv> You use a similar trick |
21:14:29 | FromDiscord | <jtv> Generate one random "master" key |
21:14:40 | FromDiscord | <4zv4l> In reply to @jtv "Yeah, sure, but anyone": isn't it easy to guess ? |
21:14:40 | FromDiscord | <jtv> For each file, hash the filename and length |
21:14:54 | FromDiscord | <jtv> encrypt that value w/ the master key |
21:15:11 | FromDiscord | <4zv4l> makes sense |
21:15:15 | FromDiscord | <jtv> Then use that 256-bit encrypted hash as the key to encrypt the file |
21:15:22 | FromDiscord | <jtv> And there, you can now use 0 as a nonce for each file |
21:15:45 | FromDiscord | <jtv> Now, just from the file name and size, the bad guy can reconstruct the file key from the one master key |
21:16:14 | FromDiscord | <4zv4l> so if the people during that time change the filename↵the bad guy can't help right ? |
21:16:53 | FromDiscord | <jtv> Well, the person whose files have been decrypted is unlikely to change the file name. |
21:17:18 | FromDiscord | <jtv> But, you can keep that info in the output file |
21:17:31 | FromDiscord | <jtv> If that really matters |
21:17:50 | FromDiscord | <jtv> i.e., encrypt, then in the file write the file name, length and ciphertext (w/ tag) |
21:19:01 | FromDiscord | <jtv> That's generally how I'd do it anyway, as I'd use the full path to each file to help ensure uniqueness of nonces |
21:20:20 | FromDiscord | <4zv4l> well, that sounds really interesting↵thank you so much for your explanation and time↵I'll try doing something similar here and see if I won't break my program again xD |
21:22:23 | FromDiscord | <jtv> LOL well I'll probably be around if you run into issues |
21:22:37 | FromDiscord | <4zv4l> In reply to @jtv "But, you can keep": if you write that in the output file, won't they see those info ? |
21:22:46 | FromDiscord | <4zv4l> oh but they still don't have the master key |
21:23:11 | FromDiscord | <jtv> Sure, but they already know what the file name and file size were, it's not data you're trying to keep secret, it's just used to compute the nonce |
21:23:21 | FromDiscord | <jtv> Yeah, it's the master key that's the secret you care about |
21:24:54 | FromDiscord | <4zv4l> In reply to @jtv "Sure, but they already": they key you mean right ? you said the nonce could be 0 using that technique |
21:25:11 | FromDiscord | <4zv4l> or using master key + nonce (nonce being the filename + size in sha256) |
21:27:50 | FromDiscord | <jtv> Right, the nonce for the key generation function |
21:29:03 | FromDiscord | <jtv> So KDF(masterKey, filename, filesize) = AES(masterkey, SHA256(filename & $(filesize)) |
21:29:12 | FromDiscord | <jtv> Would return you a key for that file |
21:29:44 | FromDiscord | <4zv4l> I'm sorry I didn't quite get this |
21:30:36 | FromDiscord | <jtv> So you break into a machine, you generate a random master key that you upload to your server. You use that to create a series of keys, via the above key derivation function (KDF) |
21:30:40 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kd7 |
21:31:08 | FromDiscord | <4zv4l> so masterkey is the key and sha256(filename & $filesize) is the nonce |
21:31:12 | FromDiscord | <jtv> No, you encrypt that hash with the "master" key |
21:31:31 | FromDiscord | <jtv> That's how you keep the target from being able to reverse engineer and decrypt their own stuff |
21:32:02 | FromDiscord | <jtv> Right, sha256(filename & $filesize) is the nonce to your KDF to get a key to encrypt that file with |
21:32:27 | FromDiscord | <jtv> Then that key can use 0 as a nonce, since the "requirement" is that key, nonce pairs cannot be reused |
21:33:00 | FromDiscord | <jtv> Each key is randomized and statistically going to be unique, so 0 is a perfectly fine nonce, as long as each target also has a random master key |
21:35:34 | FromDiscord | <4zv4l> In reply to @jtv "So KDF(masterKey, filename, filesize)": is there a short function to get the result of the `AES(masterkey, SHA256(filename & $filesize))` ? |
21:38:48 | FromDiscord | <jtv> Well, depends on the library, but it'd be fine to put AES in CTR mode for that |
21:44:11 | * | genpaku quit (Remote host closed the connection) |
21:45:42 | FromDiscord | <4zv4l> and for the encryption file still GCM ? |
21:47:49 | FromDiscord | <jtv> I would |
21:48:40 | FromDiscord | <jtv> Always worth knowing when your ciphertext has been mucked with |
21:48:43 | * | genpaku joined #nim |
22:14:27 | FromDiscord | <4zv4l> jeez finally https://media.discordapp.net/attachments/371759389889003532/1059595556357427220/image.png |
22:14:46 | FromDiscord | <4zv4l> https://media.discordapp.net/attachments/371759389889003532/1059595634631528488/aes.nim |
22:14:50 | FromDiscord | <4zv4l> probably not the best code but |
22:14:50 | FromDiscord | <4zv4l> jeez |
22:17:50 | * | wallabra quit (Ping timeout: 260 seconds) |
22:33:49 | NimEventer | New thread by jtv: A seasoned programmer's take on Nim's docs, see https://forum.nim-lang.org/t/9791 |
22:34:07 | FromDiscord | <jtv> Congrats 🙂 |
22:40:39 | * | derpydoo joined #nim |
22:41:05 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kdf |
22:43:22 | FromDiscord | <jtv> Well your master key should just be random bits, and then you use that to encrypt the hash, and as long as hash outputs never repeat you will never have an issue |
22:43:30 | FromDiscord | <jtv> Which, statistically they will not |
22:44:07 | FromDiscord | <jtv> They’d have to have the master key to be able to reconstruct generated keys |
22:45:34 | FromDiscord | <4zv4l> well thank you so much↵with you I didn't only fix my program but also improved it a lot↵thank you ^^ |
22:46:38 | * | ltriant joined #nim |
22:46:46 | FromDiscord | <jtv> My pleasure |
22:49:23 | * | azimut quit (Ping timeout: 255 seconds) |
23:02:03 | * | derpydoo quit (Ping timeout: 248 seconds) |
23:04:16 | FromDiscord | <4zv4l> to send the key to the server I guess using DNS + asym enc to send it, would be the best bet ? |
23:04:30 | FromDiscord | <4zv4l> but then for the test I can't just use netcat xD |
23:05:35 | FromDiscord | <jtv> I guess, I’d probably just write to an S3 bucket and be done. |
23:06:48 | FromDiscord | <jtv> But in a real world scenario yeah you’d generally encrypt to some private key and post it somewhere |
23:07:58 | FromDiscord | <4zv4l> oh right, I should add the full path in the code rather than using the filename only↵that's in case the file has been copied somewhere else on the disk right ? |
23:08:40 | * | ehmry quit (Ping timeout: 252 seconds) |
23:10:35 | * | ehmry joined #nim |
23:12:06 | FromDiscord | <jtv> Yup |
23:12:38 | FromDiscord | <jtv> Like someone nuked that machine but wants to restore from a backup, etc |
23:12:48 | FromDiscord | <jtv> But that's encrypted 🙂 |
23:14:27 | nmz | So Nim requires 3gb to build |
23:14:28 | FromDiscord | <4zv4l> what do you mean ? if they have a backup they're good aren't they ?↵except obviously if the backup is on the server itself 🤡 |
23:14:40 | nmz | my pc just hanged, would be nice to put it somewhere in the install instructions |
23:14:48 | nmz | toypc* |
23:17:12 | FromDiscord | <jtv> If their only backup is post-encryption |
23:17:53 | FromDiscord | <jtv> Generally if someone gets on your laptop and encrypts files, IT isn't going to have you keep using that laptop, but I've seen them rebuild the laptop... |
23:32:39 | FromDiscord | <4zv4l> In reply to @jtv "If their only backup": yes right, get it |
23:32:49 | FromDiscord | <4zv4l> In reply to @jtv "Generally if someone gets": well can wipe and start over 🥺 |
23:32:55 | * | wallabra joined #nim |